/[dynamips]/trunk/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 /trunk/pci_dev.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (hide annotations)
Sat Oct 6 16:45:40 2007 UTC (11 years, 8 months ago) by dpavlin
File MIME type: text/plain
File size: 5091 byte(s)
make working copy

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

  ViewVC Help
Powered by ViewVC 1.1.26