Statistics
| Branch: | Revision:

root / hw / pci.h @ 5703c174

History | View | Annotate | Download (6 kB)

1 87ecb68b pbrook
#ifndef QEMU_PCI_H
2 87ecb68b pbrook
#define QEMU_PCI_H
3 87ecb68b pbrook
4 87ecb68b pbrook
/* PCI includes legacy ISA access.  */
5 87ecb68b pbrook
#include "isa.h"
6 87ecb68b pbrook
7 87ecb68b pbrook
/* PCI bus */
8 87ecb68b pbrook
9 87ecb68b pbrook
extern target_phys_addr_t pci_mem_base;
10 87ecb68b pbrook
11 d350d97d aliguori
/* see pci-ids.txt */
12 d350d97d aliguori
#define PCI_VENDOR_ID_REDHAT_QUMRANET    0x1af4
13 d350d97d aliguori
#define PCI_SUBVENDOR_ID_REDHAT_QUMRANET 0x1af4
14 d350d97d aliguori
#define PCI_SUBDEVICE_ID_QEMU            0x1100
15 d350d97d aliguori
16 d350d97d aliguori
#define PCI_DEVICE_ID_VIRTIO_NET         0x1000
17 d350d97d aliguori
#define PCI_DEVICE_ID_VIRTIO_BLOCK       0x1001
18 d350d97d aliguori
#define PCI_DEVICE_ID_VIRTIO_BALLOON     0x1002
19 d350d97d aliguori
20 87ecb68b pbrook
typedef void PCIConfigWriteFunc(PCIDevice *pci_dev,
21 87ecb68b pbrook
                                uint32_t address, uint32_t data, int len);
22 87ecb68b pbrook
typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev,
23 87ecb68b pbrook
                                   uint32_t address, int len);
24 87ecb68b pbrook
typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num,
25 87ecb68b pbrook
                                uint32_t addr, uint32_t size, int type);
26 87ecb68b pbrook
27 87ecb68b pbrook
#define PCI_ADDRESS_SPACE_MEM                0x00
28 87ecb68b pbrook
#define PCI_ADDRESS_SPACE_IO                0x01
29 87ecb68b pbrook
#define PCI_ADDRESS_SPACE_MEM_PREFETCH        0x08
30 87ecb68b pbrook
31 87ecb68b pbrook
typedef struct PCIIORegion {
32 87ecb68b pbrook
    uint32_t addr; /* current PCI mapping address. -1 means not mapped */
33 87ecb68b pbrook
    uint32_t size;
34 87ecb68b pbrook
    uint8_t type;
35 87ecb68b pbrook
    PCIMapIORegionFunc *map_func;
36 87ecb68b pbrook
} PCIIORegion;
37 87ecb68b pbrook
38 87ecb68b pbrook
#define PCI_ROM_SLOT 6
39 87ecb68b pbrook
#define PCI_NUM_REGIONS 7
40 87ecb68b pbrook
41 87ecb68b pbrook
#define PCI_DEVICES_MAX 64
42 87ecb68b pbrook
43 87ecb68b pbrook
#define PCI_VENDOR_ID                0x00        /* 16 bits */
44 87ecb68b pbrook
#define PCI_DEVICE_ID                0x02        /* 16 bits */
45 87ecb68b pbrook
#define PCI_COMMAND                0x04        /* 16 bits */
46 87ecb68b pbrook
#define  PCI_COMMAND_IO                0x1        /* Enable response in I/O space */
47 87ecb68b pbrook
#define  PCI_COMMAND_MEMORY        0x2        /* Enable response in Memory space */
48 d350d97d aliguori
#define PCI_REVISION            0x08
49 87ecb68b pbrook
#define PCI_CLASS_DEVICE        0x0a    /* Device class */
50 d350d97d aliguori
#define PCI_SUBVENDOR_ID        0x2c        /* 16 bits */
51 d350d97d aliguori
#define PCI_SUBDEVICE_ID        0x2e        /* 16 bits */
52 87ecb68b pbrook
#define PCI_INTERRUPT_LINE        0x3c        /* 8 bits */
53 87ecb68b pbrook
#define PCI_INTERRUPT_PIN        0x3d        /* 8 bits */
54 87ecb68b pbrook
#define PCI_MIN_GNT                0x3e        /* 8 bits */
55 87ecb68b pbrook
#define PCI_MAX_LAT                0x3f        /* 8 bits */
56 87ecb68b pbrook
57 8098ed41 aurel32
/* Bits in the PCI Status Register (PCI 2.3 spec) */
58 8098ed41 aurel32
#define PCI_STATUS_RESERVED1        0x007
59 8098ed41 aurel32
#define PCI_STATUS_INT_STATUS        0x008
60 8098ed41 aurel32
#define PCI_STATUS_CAPABILITIES        0x010
61 8098ed41 aurel32
#define PCI_STATUS_66MHZ        0x020
62 8098ed41 aurel32
#define PCI_STATUS_RESERVED2        0x040
63 8098ed41 aurel32
#define PCI_STATUS_FAST_BACK        0x080
64 8098ed41 aurel32
#define PCI_STATUS_DEVSEL        0x600
65 8098ed41 aurel32
66 8098ed41 aurel32
#define PCI_STATUS_RESERVED_MASK_LO (PCI_STATUS_RESERVED1 | \
67 8098ed41 aurel32
                PCI_STATUS_INT_STATUS | PCI_STATUS_CAPABILITIES | \
68 8098ed41 aurel32
                PCI_STATUS_66MHZ | PCI_STATUS_RESERVED2 | PCI_STATUS_FAST_BACK)
69 8098ed41 aurel32
70 8098ed41 aurel32
#define PCI_STATUS_RESERVED_MASK_HI (PCI_STATUS_DEVSEL >> 8)
71 8098ed41 aurel32
72 475dc65f aurel32
/* Bits in the PCI Command Register (PCI 2.3 spec) */
73 475dc65f aurel32
#define PCI_COMMAND_RESERVED        0xf800
74 475dc65f aurel32
75 475dc65f aurel32
#define PCI_COMMAND_RESERVED_MASK_HI (PCI_COMMAND_RESERVED >> 8)
76 475dc65f aurel32
77 87ecb68b pbrook
struct PCIDevice {
78 87ecb68b pbrook
    /* PCI config space */
79 87ecb68b pbrook
    uint8_t config[256];
80 87ecb68b pbrook
81 87ecb68b pbrook
    /* the following fields are read only */
82 87ecb68b pbrook
    PCIBus *bus;
83 87ecb68b pbrook
    int devfn;
84 87ecb68b pbrook
    char name[64];
85 87ecb68b pbrook
    PCIIORegion io_regions[PCI_NUM_REGIONS];
86 87ecb68b pbrook
87 87ecb68b pbrook
    /* do not access the following fields */
88 87ecb68b pbrook
    PCIConfigReadFunc *config_read;
89 87ecb68b pbrook
    PCIConfigWriteFunc *config_write;
90 87ecb68b pbrook
    /* ??? This is a PC-specific hack, and should be removed.  */
91 87ecb68b pbrook
    int irq_index;
92 87ecb68b pbrook
93 87ecb68b pbrook
    /* IRQ objects for the INTA-INTD pins.  */
94 87ecb68b pbrook
    qemu_irq *irq;
95 87ecb68b pbrook
96 87ecb68b pbrook
    /* Current IRQ levels.  Used internally by the generic PCI code.  */
97 87ecb68b pbrook
    int irq_state[4];
98 87ecb68b pbrook
};
99 87ecb68b pbrook
100 87ecb68b pbrook
PCIDevice *pci_register_device(PCIBus *bus, const char *name,
101 87ecb68b pbrook
                               int instance_size, int devfn,
102 87ecb68b pbrook
                               PCIConfigReadFunc *config_read,
103 87ecb68b pbrook
                               PCIConfigWriteFunc *config_write);
104 87ecb68b pbrook
105 87ecb68b pbrook
void pci_register_io_region(PCIDevice *pci_dev, int region_num,
106 87ecb68b pbrook
                            uint32_t size, int type,
107 87ecb68b pbrook
                            PCIMapIORegionFunc *map_func);
108 87ecb68b pbrook
109 87ecb68b pbrook
uint32_t pci_default_read_config(PCIDevice *d,
110 87ecb68b pbrook
                                 uint32_t address, int len);
111 87ecb68b pbrook
void pci_default_write_config(PCIDevice *d,
112 87ecb68b pbrook
                              uint32_t address, uint32_t val, int len);
113 87ecb68b pbrook
void pci_device_save(PCIDevice *s, QEMUFile *f);
114 87ecb68b pbrook
int pci_device_load(PCIDevice *s, QEMUFile *f);
115 87ecb68b pbrook
116 87ecb68b pbrook
typedef void (*pci_set_irq_fn)(qemu_irq *pic, int irq_num, int level);
117 87ecb68b pbrook
typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);
118 87ecb68b pbrook
PCIBus *pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
119 87ecb68b pbrook
                         qemu_irq *pic, int devfn_min, int nirq);
120 87ecb68b pbrook
121 cb457d76 aliguori
void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn,
122 cb457d76 aliguori
                  const char *default_model);
123 87ecb68b pbrook
void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);
124 87ecb68b pbrook
uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
125 87ecb68b pbrook
int pci_bus_num(PCIBus *s);
126 87ecb68b pbrook
void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d));
127 87ecb68b pbrook
128 87ecb68b pbrook
void pci_info(void);
129 87ecb68b pbrook
PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
130 87ecb68b pbrook
                        pci_map_irq_fn map_irq, const char *name);
131 87ecb68b pbrook
132 87ecb68b pbrook
/* lsi53c895a.c */
133 e4bcb14c ths
#define LSI_MAX_DEVS 7
134 87ecb68b pbrook
void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id);
135 87ecb68b pbrook
void *lsi_scsi_init(PCIBus *bus, int devfn);
136 87ecb68b pbrook
137 87ecb68b pbrook
/* vmware_vga.c */
138 87ecb68b pbrook
void pci_vmsvga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
139 87ecb68b pbrook
                     unsigned long vga_ram_offset, int vga_ram_size);
140 87ecb68b pbrook
141 87ecb68b pbrook
/* usb-uhci.c */
142 87ecb68b pbrook
void usb_uhci_piix3_init(PCIBus *bus, int devfn);
143 87ecb68b pbrook
void usb_uhci_piix4_init(PCIBus *bus, int devfn);
144 87ecb68b pbrook
145 87ecb68b pbrook
/* usb-ohci.c */
146 87ecb68b pbrook
void usb_ohci_init_pci(struct PCIBus *bus, int num_ports, int devfn);
147 87ecb68b pbrook
148 87ecb68b pbrook
/* eepro100.c */
149 87ecb68b pbrook
150 87ecb68b pbrook
void pci_i82551_init(PCIBus *bus, NICInfo *nd, int devfn);
151 87ecb68b pbrook
void pci_i82557b_init(PCIBus *bus, NICInfo *nd, int devfn);
152 87ecb68b pbrook
void pci_i82559er_init(PCIBus *bus, NICInfo *nd, int devfn);
153 87ecb68b pbrook
154 87ecb68b pbrook
/* ne2000.c */
155 87ecb68b pbrook
156 87ecb68b pbrook
void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn);
157 87ecb68b pbrook
158 87ecb68b pbrook
/* rtl8139.c */
159 87ecb68b pbrook
160 87ecb68b pbrook
void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn);
161 87ecb68b pbrook
162 7c23b892 balrog
/* e1000.c */
163 7c23b892 balrog
void pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn);
164 7c23b892 balrog
165 87ecb68b pbrook
/* pcnet.c */
166 87ecb68b pbrook
void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn);
167 87ecb68b pbrook
168 87ecb68b pbrook
/* prep_pci.c */
169 87ecb68b pbrook
PCIBus *pci_prep_init(qemu_irq *pic);
170 87ecb68b pbrook
171 87ecb68b pbrook
/* apb_pci.c */
172 c190ea07 blueswir1
PCIBus *pci_apb_init(target_phys_addr_t special_base,
173 c190ea07 blueswir1
                     target_phys_addr_t mem_base,
174 c190ea07 blueswir1
                     qemu_irq *pic, PCIBus **bus2, PCIBus **bus3);
175 87ecb68b pbrook
176 b79e1752 aurel32
/* sh_pci.c */
177 b79e1752 aurel32
PCIBus *sh_pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
178 b79e1752 aurel32
                            qemu_irq *pic, int devfn_min, int nirq);
179 b79e1752 aurel32
180 87ecb68b pbrook
#endif