Statistics
| Branch: | Revision:

root / hw / spapr_pci.h @ 5e22c276

History | View | Annotate | Download (2.5 kB)

1 3384f95c David Gibson
/*
2 3384f95c David Gibson
 * QEMU SPAPR PCI BUS definitions
3 3384f95c David Gibson
 *
4 3384f95c David Gibson
 * Copyright (c) 2011 Alexey Kardashevskiy <aik@au1.ibm.com>
5 3384f95c David Gibson
 *
6 3384f95c David Gibson
 * This library is free software; you can redistribute it and/or
7 3384f95c David Gibson
 * modify it under the terms of the GNU Lesser General Public
8 3384f95c David Gibson
 * License as published by the Free Software Foundation; either
9 3384f95c David Gibson
 * version 2 of the License, or (at your option) any later version.
10 3384f95c David Gibson
 *
11 3384f95c David Gibson
 * This library is distributed in the hope that it will be useful,
12 3384f95c David Gibson
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 3384f95c David Gibson
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 3384f95c David Gibson
 * Lesser General Public License for more details.
15 3384f95c David Gibson
 *
16 3384f95c David Gibson
 * You should have received a copy of the GNU Lesser General Public
17 3384f95c David Gibson
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 3384f95c David Gibson
 */
19 3384f95c David Gibson
#if !defined(__HW_SPAPR_H__)
20 3384f95c David Gibson
#error Please include spapr.h before this file!
21 3384f95c David Gibson
#endif
22 3384f95c David Gibson
23 3384f95c David Gibson
#if !defined(__HW_SPAPR_PCI_H__)
24 3384f95c David Gibson
#define __HW_SPAPR_PCI_H__
25 3384f95c David Gibson
26 a2cb15b0 Michael S. Tsirkin
#include "hw/pci/pci.h"
27 a2cb15b0 Michael S. Tsirkin
#include "hw/pci/pci_host.h"
28 3384f95c David Gibson
#include "hw/xics.h"
29 3384f95c David Gibson
30 0ee2c058 Alexey Kardashevskiy
#define SPAPR_MSIX_MAX_DEVS 32
31 0ee2c058 Alexey Kardashevskiy
32 8c9f64df Andreas Färber
#define TYPE_SPAPR_PCI_HOST_BRIDGE "spapr-pci-host-bridge"
33 8c9f64df Andreas Färber
34 8c9f64df Andreas Färber
#define SPAPR_PCI_HOST_BRIDGE(obj) \
35 8c9f64df Andreas Färber
    OBJECT_CHECK(sPAPRPHBState, (obj), TYPE_SPAPR_PCI_HOST_BRIDGE)
36 8c9f64df Andreas Färber
37 3384f95c David Gibson
typedef struct sPAPRPHBState {
38 67c332fd Andreas Färber
    PCIHostState parent_obj;
39 3384f95c David Gibson
40 3384f95c David Gibson
    uint64_t buid;
41 298a9710 David Gibson
    char *busname;
42 298a9710 David Gibson
    char *dtbusname;
43 3384f95c David Gibson
44 3384f95c David Gibson
    MemoryRegion memspace, iospace;
45 a8170e5e Avi Kivity
    hwaddr mem_win_addr, mem_win_size, io_win_addr, io_win_size;
46 a8170e5e Avi Kivity
    hwaddr msi_win_addr;
47 a3cfa18e David Gibson
    MemoryRegion memwindow, iowindow, msiwindow;
48 0ee2c058 Alexey Kardashevskiy
49 5c4cbcf2 Alexey Kardashevskiy
    uint32_t dma_liobn;
50 5c4cbcf2 Alexey Kardashevskiy
    uint64_t dma_window_start;
51 5c4cbcf2 Alexey Kardashevskiy
    uint64_t dma_window_size;
52 edded454 David Gibson
    DMAContext *dma;
53 3384f95c David Gibson
54 3384f95c David Gibson
    struct {
55 a307d594 Alexey Kardashevskiy
        uint32_t irq;
56 7fb0bd34 David Gibson
    } lsi_table[PCI_NUM_PINS];
57 3384f95c David Gibson
58 0ee2c058 Alexey Kardashevskiy
    struct {
59 0ee2c058 Alexey Kardashevskiy
        uint32_t config_addr;
60 0ee2c058 Alexey Kardashevskiy
        uint32_t irq;
61 0ee2c058 Alexey Kardashevskiy
        int nvec;
62 0ee2c058 Alexey Kardashevskiy
    } msi_table[SPAPR_MSIX_MAX_DEVS];
63 0ee2c058 Alexey Kardashevskiy
64 3384f95c David Gibson
    QLIST_ENTRY(sPAPRPHBState) list;
65 3384f95c David Gibson
} sPAPRPHBState;
66 3384f95c David Gibson
67 a307d594 Alexey Kardashevskiy
static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRPHBState *phb, int pin)
68 a307d594 Alexey Kardashevskiy
{
69 a307d594 Alexey Kardashevskiy
    return xics_get_qirq(spapr->icp, phb->lsi_table[pin].irq);
70 a307d594 Alexey Kardashevskiy
}
71 a307d594 Alexey Kardashevskiy
72 3384f95c David Gibson
#define SPAPR_PCI_MEM_WIN_BUS_OFFSET 0x80000000ULL
73 3384f95c David Gibson
#define SPAPR_PCI_IO_WIN_SIZE        0x10000
74 3384f95c David Gibson
75 3384f95c David Gibson
void spapr_create_phb(sPAPREnvironment *spapr,
76 3384f95c David Gibson
                      const char *busname, uint64_t buid,
77 3384f95c David Gibson
                      uint64_t mem_win_addr, uint64_t mem_win_size,
78 0ee2c058 Alexey Kardashevskiy
                      uint64_t io_win_addr, uint64_t msi_win_addr);
79 3384f95c David Gibson
80 e0fdbd7c Alexey Kardashevskiy
int spapr_populate_pci_dt(sPAPRPHBState *phb,
81 e0fdbd7c Alexey Kardashevskiy
                          uint32_t xics_phandle,
82 e0fdbd7c Alexey Kardashevskiy
                          void *fdt);
83 3384f95c David Gibson
84 fa28f71b Alexey Kardashevskiy
void spapr_pci_rtas_init(void);
85 fa28f71b Alexey Kardashevskiy
86 3384f95c David Gibson
#endif /* __HW_SPAPR_PCI_H__ */