/[dynamips]/upstream/dynamips-0.2.6-RC2/pci_dev.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /upstream/dynamips-0.2.6-RC2/pci_dev.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Sat Oct 6 16:01:44 2007 UTC (14 years, 9 months ago) by dpavlin
Original Path: upstream/dynamips-0.2.5/pci_dev.h
File MIME type: text/plain
File size: 5126 byte(s)
import 0.2.5 from upstream

1 dpavlin 1 /*
2     * Cisco 7200 (Predator) simulation platform.
3     * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)
4     */
5    
6     #ifndef __PCI_DEV_H__
7     #define __PCI_DEV_H__
8    
9     #include "utils.h"
10     //#include "pcireg.h"
11    
12     #define PCI_BUS_ADDR 0xcf8
13     #define PCI_BUS_DATA 0xcfc
14    
15     /* PCI ID (Vendor + Device) register */
16     #define PCI_REG_ID 0x00
17    
18     /* PCI Base Address Registers (BAR) */
19     #define PCI_REG_BAR0 0x10
20     #define PCI_REG_BAR1 0x14
21     #define PCI_REG_BAR2 0x18
22     #define PCI_REG_BAR3 0x1c
23     #define PCI_REG_BAR4 0x20
24     #define PCI_REG_BAR5 0x24
25    
26     /* Forward declaration for PCI device */
27     typedef struct pci_device pci_dev_t;
28    
29     /* PCI function prototypes */
30     typedef void (*pci_init_t)(pci_dev_t *dev);
31     typedef m_uint32_t (*pci_reg_read_t)(cpu_mips_t *cpu,pci_dev_t *dev,int reg);
32     typedef void (*pci_reg_write_t)(cpu_mips_t *cpu,pci_dev_t *dev,int reg,
33     m_uint32_t value);
34     /* PCI device */
35     struct pci_device {
36     char *name;
37     u_int vendor_id,product_id;
38     int device,function,irq;
39     void *priv_data;
40    
41     /* Parent bus */
42     struct pci_bus *pci_bus;
43    
44     pci_init_t init;
45     pci_reg_read_t read_register;
46     pci_reg_write_t write_register;
47    
48     struct pci_device *next,**pprev;
49     };
50    
51     /* PCI bus */
52     struct pci_bus {
53     char *name;
54     m_uint32_t pci_addr;
55    
56     /* Bus number */
57     int bus;
58    
59     /* PCI device list on this bus */
60     struct pci_device *dev_list;
61    
62     /* PCI bridges to access other busses */
63     struct pci_bridge *bridge_list;
64     };
65    
66     /* PCI bridge */
67     struct pci_bridge {
68     int pri_bus; /* Primary Bus */
69     int sec_bus; /* Secondary Bus */
70     int sub_bus; /* Subordinate Bus */
71    
72     int skip_bus_check;
73    
74     /* Bus configuration register */
75     m_uint32_t cfg_reg_bus;
76    
77     /* PCI bridge device */
78     struct pci_device *pci_dev;
79    
80     /* Secondary PCI bus */
81     struct pci_bus *pci_bus;
82    
83     /* Fallback handlers to read/write config registers */
84     pci_reg_read_t fallback_read;
85     pci_reg_write_t fallback_write;
86    
87     struct pci_bridge *next,**pprev;
88     };
89    
90     /* PCI IO device */
91     struct pci_io_device {
92     m_uint32_t start,end;
93     struct vdevice *real_dev;
94     dev_handler_t handler;
95     struct pci_io_device *next,**pprev;
96     };
97    
98     /* Trigger a PCI device IRQ */
99     void pci_dev_trigger_irq(vm_instance_t *vm,struct pci_device *dev);
100    
101     /* Clear a PCI device IRQ */
102     void pci_dev_clear_irq(vm_instance_t *vm,struct pci_device *dev);
103    
104     /* PCI bus lookup */
105     struct pci_bus *pci_bus_lookup(struct pci_bus *pci_bus_root,int bus);
106    
107     /* PCI device local lookup */
108     struct pci_device *pci_dev_lookup_local(struct pci_bus *pci_bus,
109     int device,int function);
110    
111     /* PCI device lookup */
112     struct pci_device *pci_dev_lookup(struct pci_bus *pci_bus_root,
113     int bus,int device,int function);
114    
115     /* Handle the address register access */
116     void pci_dev_addr_handler(cpu_mips_t *cpu,struct pci_bus *pci_bus,
117     u_int op_type,int swap,m_uint64_t *data);
118    
119     /* Handle the data register access */
120     void pci_dev_data_handler(cpu_mips_t *cpu,struct pci_bus *pci_bus,
121     u_int op_type,int swap,m_uint64_t *data);
122    
123     /* Add a PCI bridge */
124     struct pci_bridge *pci_bridge_add(struct pci_bus *pci_bus);
125    
126     /* Remove a PCI bridge */
127     void pci_bridge_remove(struct pci_bridge *bridge);
128    
129     /* Map secondary bus to a PCI bridge */
130     void pci_bridge_map_bus(struct pci_bridge *bridge,struct pci_bus *pci_bus);
131    
132     /* Set PCI bridge bus info */
133     void pci_bridge_set_bus_info(struct pci_bridge *bridge,
134     int pri_bus,int sec_bus,int sub_bus);
135    
136     /* Add a PCI device */
137     struct pci_device *
138     pci_dev_add(struct pci_bus *pci_bus,
139     char *name,u_int vendor_id,u_int product_id,
140     int device,int function,int irq,
141     void *priv_data,pci_init_t init,
142     pci_reg_read_t read_register,
143     pci_reg_write_t write_register);
144    
145     /* Add a basic PCI device that just returns a Vendor/Product ID */
146     struct pci_device *
147     pci_dev_add_basic(struct pci_bus *pci_bus,
148     char *name,u_int vendor_id,u_int product_id,
149     int device,int function);
150    
151     /* Remove a PCI device */
152     void pci_dev_remove(struct pci_device *dev);
153    
154     /* Remove a PCI device given its ID (bus,device,function) */
155     int pci_dev_remove_by_id(struct pci_bus *pci_bus,
156     int bus,int device,int function);
157    
158     /* Remove a PCI device given its name */
159     int pci_dev_remove_by_name(struct pci_bus *pci_bus,char *name);
160    
161     /* Create a PCI bus */
162     struct pci_bus *pci_bus_create(char *name,int bus);
163    
164     /* Delete a PCI bus */
165     void pci_bus_remove(struct pci_bus *pci_bus);
166    
167     /* Create a PCI bridge device */
168     struct pci_device *pci_bridge_create_dev(struct pci_bus *pci_bus,char *name,
169     u_int vendor_id,u_int product_id,
170     int device,int function,
171     struct pci_bus *sec_bus,
172     pci_reg_read_t fallback_read,
173     pci_reg_write_t fallback_write);
174    
175     /* Show PCI device list */
176     void pci_dev_show_list(struct pci_bus *pci_bus);
177    
178     #endif

  ViewVC Help
Powered by ViewVC 1.1.26