Statistics
| Branch: | Revision:

root / hw / spapr_pci.h @ 5f893b4e

History | View | Annotate | Download (2.3 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 7fb0bd34 David Gibson
#include "hw/pci.h"
27 3384f95c David Gibson
#include "hw/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 3384f95c David Gibson
typedef struct sPAPRPHBState {
33 3384f95c David Gibson
    PCIHostState host_state;
34 3384f95c David Gibson
35 3384f95c David Gibson
    uint64_t buid;
36 298a9710 David Gibson
    char *busname;
37 298a9710 David Gibson
    char *dtbusname;
38 3384f95c David Gibson
39 3384f95c David Gibson
    MemoryRegion memspace, iospace;
40 298a9710 David Gibson
    target_phys_addr_t mem_win_addr, mem_win_size, io_win_addr, io_win_size;
41 0ee2c058 Alexey Kardashevskiy
    target_phys_addr_t msi_win_addr;
42 0ee2c058 Alexey Kardashevskiy
    MemoryRegion memwindow, iowindow, msiwindow;
43 0ee2c058 Alexey Kardashevskiy
44 5c4cbcf2 Alexey Kardashevskiy
    uint32_t dma_liobn;
45 5c4cbcf2 Alexey Kardashevskiy
    uint64_t dma_window_start;
46 5c4cbcf2 Alexey Kardashevskiy
    uint64_t dma_window_size;
47 edded454 David Gibson
    DMAContext *dma;
48 3384f95c David Gibson
49 3384f95c David Gibson
    struct {
50 a307d594 Alexey Kardashevskiy
        uint32_t irq;
51 7fb0bd34 David Gibson
    } lsi_table[PCI_NUM_PINS];
52 3384f95c David Gibson
53 0ee2c058 Alexey Kardashevskiy
    struct {
54 0ee2c058 Alexey Kardashevskiy
        uint32_t config_addr;
55 0ee2c058 Alexey Kardashevskiy
        uint32_t irq;
56 0ee2c058 Alexey Kardashevskiy
        int nvec;
57 0ee2c058 Alexey Kardashevskiy
    } msi_table[SPAPR_MSIX_MAX_DEVS];
58 0ee2c058 Alexey Kardashevskiy
59 3384f95c David Gibson
    QLIST_ENTRY(sPAPRPHBState) list;
60 3384f95c David Gibson
} sPAPRPHBState;
61 3384f95c David Gibson
62 a307d594 Alexey Kardashevskiy
static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRPHBState *phb, int pin)
63 a307d594 Alexey Kardashevskiy
{
64 a307d594 Alexey Kardashevskiy
    return xics_get_qirq(spapr->icp, phb->lsi_table[pin].irq);
65 a307d594 Alexey Kardashevskiy
}
66 a307d594 Alexey Kardashevskiy
67 3384f95c David Gibson
#define SPAPR_PCI_MEM_WIN_BUS_OFFSET 0x80000000ULL
68 3384f95c David Gibson
#define SPAPR_PCI_IO_WIN_SIZE        0x10000
69 3384f95c David Gibson
70 3384f95c David Gibson
void spapr_create_phb(sPAPREnvironment *spapr,
71 3384f95c David Gibson
                      const char *busname, uint64_t buid,
72 3384f95c David Gibson
                      uint64_t mem_win_addr, uint64_t mem_win_size,
73 0ee2c058 Alexey Kardashevskiy
                      uint64_t io_win_addr, uint64_t msi_win_addr);
74 3384f95c David Gibson
75 e0fdbd7c Alexey Kardashevskiy
int spapr_populate_pci_dt(sPAPRPHBState *phb,
76 e0fdbd7c Alexey Kardashevskiy
                          uint32_t xics_phandle,
77 e0fdbd7c Alexey Kardashevskiy
                          void *fdt);
78 3384f95c David Gibson
79 fa28f71b Alexey Kardashevskiy
void spapr_pci_rtas_init(void);
80 fa28f71b Alexey Kardashevskiy
81 3384f95c David Gibson
#endif /* __HW_SPAPR_PCI_H__ */