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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (hide annotations)
Sat Oct 6 16:23:47 2007 UTC (16 years, 5 months ago) by dpavlin
Original Path: upstream/dynamips-0.2.7-RC1/device.h
File MIME type: text/plain
File size: 7956 byte(s)
dynamips-0.2.7-RC1

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 __DEVICE_H__
7     #define __DEVICE_H__
8    
9     #include <sys/types.h>
10     #include "utils.h"
11     #include "cpu.h"
12     #include "net_io.h"
13     #include "vm.h"
14    
15     /* Device Flags */
16 dpavlin 7 #define VDEVICE_FLAG_NO_MTS_MMAP 0x01 /* Prevent MMAPed access by MTS */
17     #define VDEVICE_FLAG_CACHING 0x02 /* Device does support caching */
18     #define VDEVICE_FLAG_REMAP 0x04 /* Physical address remapping */
19     #define VDEVICE_FLAG_SYNC 0x08 /* Forced sync */
20     #define VDEVICE_FLAG_SPARSE 0x10 /* Sparse device */
21     #define VDEVICE_FLAG_GHOST 0x20 /* Ghost device */
22 dpavlin 1
23 dpavlin 7 #define VDEVICE_PTE_DIRTY 0x01
24    
25     typedef void *(*dev_handler_t)(cpu_gen_t *cpu,struct vdevice *dev,
26 dpavlin 1 m_uint32_t offset,u_int op_size,u_int op_type,
27     m_uint64_t *data);
28    
29     /* Virtual Device */
30     struct vdevice {
31     char *name;
32     u_int id;
33     m_uint64_t phys_addr;
34     m_uint32_t phys_len;
35     m_iptr_t host_addr;
36     void *priv_data;
37     int flags;
38     int fd;
39     dev_handler_t handler;
40 dpavlin 7 m_iptr_t *sparse_map;
41 dpavlin 1 struct vdevice *next,**pprev;
42     };
43    
44     /* PCI part */
45     #include "pci_dev.h"
46    
47     /* device access function */
48     static forced_inline
49 dpavlin 7 void *dev_access_fast(cpu_gen_t *cpu,u_int dev_id,m_uint32_t offset,
50 dpavlin 1 u_int op_size,u_int op_type,m_uint64_t *data)
51     {
52     struct vdevice *dev = cpu->vm->dev_array[dev_id];
53    
54     if (unlikely(!dev)) {
55     cpu_log(cpu,"dev_access_fast","null handler (dev_id=%u,offset=0x%x)\n",
56     dev_id,offset);
57     return NULL;
58     }
59    
60     return(dev->handler(cpu,dev,offset,op_size,op_type,data));
61     }
62    
63     /* Get device by ID */
64     struct vdevice *dev_get_by_id(vm_instance_t *vm,u_int dev_id);
65    
66     /* Get device by name */
67     struct vdevice *dev_get_by_name(vm_instance_t *vm,char *name);
68    
69     /* Device lookup by physical address */
70     struct vdevice *dev_lookup(vm_instance_t *vm,m_uint64_t phys_addr,int cached);
71    
72     /* Find the next device after the specified address */
73     struct vdevice *dev_lookup_next(vm_instance_t *vm,m_uint64_t phys_addr,
74     struct vdevice *dev_start,int cached);
75    
76     /* Initialize a device */
77     void dev_init(struct vdevice *dev);
78    
79     /* Allocate a device */
80     struct vdevice *dev_create(char *name);
81    
82     /* Remove a device */
83     void dev_remove(vm_instance_t *vm,struct vdevice *dev);
84    
85     /* Show properties of a device */
86     void dev_show(struct vdevice *dev);
87    
88     /* Show the device list */
89     void dev_show_list(vm_instance_t *vm);
90    
91     /* device access function */
92 dpavlin 7 void *dev_access(cpu_gen_t *cpu,u_int dev_id,m_uint32_t offset,
93 dpavlin 1 u_int op_size,u_int op_type,m_uint64_t *data);
94    
95 dpavlin 4 /* Synchronize memory for a memory-mapped (mmap) device */
96     int dev_sync(struct vdevice *dev);
97    
98 dpavlin 1 /* Remap a device at specified physical address */
99     struct vdevice *dev_remap(char *name,struct vdevice *orig,
100     m_uint64_t paddr,m_uint32_t len);
101    
102     /* Create a RAM device */
103 dpavlin 7 struct vdevice *dev_create_ram(vm_instance_t *vm,char *name,
104     int sparse,char *filename,
105 dpavlin 1 m_uint64_t paddr,m_uint32_t len);
106    
107 dpavlin 4 /* Create a ghosted RAM device */
108     struct vdevice *
109 dpavlin 7 dev_create_ghost_ram(vm_instance_t *vm,char *name,int sparse,char *filename,
110 dpavlin 4 m_uint64_t paddr,m_uint32_t len);
111    
112 dpavlin 1 /* Create a memory alias */
113     struct vdevice *dev_create_ram_alias(vm_instance_t *vm,char *name,char *orig,
114     m_uint64_t paddr,m_uint32_t len);
115    
116 dpavlin 7 /* Initialize a sparse device */
117     int dev_sparse_init(struct vdevice *dev);
118    
119     /* Shutdown sparse device structures */
120     int dev_sparse_shutdown(struct vdevice *dev);
121    
122     /* Get an host address for a sparse device */
123     m_iptr_t dev_sparse_get_host_addr(vm_instance_t *vm,struct vdevice *dev,
124     m_uint64_t paddr,u_int op_type,int *cow);
125    
126 dpavlin 1 /* Create a dummy console */
127     int dev_create_dummy_console(vm_instance_t *vm);
128    
129     /* Initialized a zeroed memory zone */
130     int dev_zero_init(vm_instance_t *vm,char *name,
131     m_uint64_t paddr,m_uint32_t len);
132    
133 dpavlin 7 /* Initialized a byte-swap device */
134     int dev_bswap_init(vm_instance_t *vm,char *name,
135     m_uint64_t paddr,m_uint32_t len,m_uint64_t remap_addr);
136    
137 dpavlin 1 /* Initialize a RAM zone */
138 dpavlin 4 int dev_ram_init(vm_instance_t *vm,char *name,int use_mmap,int delete_file,
139 dpavlin 7 char *alternate_name,int sparse,
140     m_uint64_t paddr,m_uint32_t len);
141 dpavlin 1
142 dpavlin 4 /* Initialize a ghosted RAM zone */
143 dpavlin 7 int dev_ram_ghost_init(vm_instance_t *vm,char *name,int sparse,char *filename,
144 dpavlin 4 m_uint64_t paddr,m_uint32_t len);
145    
146 dpavlin 1 /* Create the NVRAM device */
147     int dev_nvram_init(vm_instance_t *vm,char *name,
148     m_uint64_t paddr,m_uint32_t len,
149     u_int *conf_reg);
150    
151     /* Create a 8 Mb bootflash */
152     int dev_bootflash_init(vm_instance_t *vm,char *name,
153     m_uint64_t paddr,m_uint32_t len);
154    
155 dpavlin 4 /* Create a Flash device */
156     vm_obj_t *dev_flash_init(vm_instance_t *vm,char *name,
157     m_uint64_t paddr,m_uint32_t len);
158 dpavlin 1
159 dpavlin 4 /* Copy data directly to a flash device */
160     int dev_flash_copy_data(vm_obj_t *obj,m_uint32_t offset,
161     u_char *ptr,ssize_t len);
162 dpavlin 1
163     /* dev_dec21050_init() */
164     int dev_dec21050_init(struct pci_bus *pci_bus,int pci_device,
165     struct pci_bus *sec_bus);
166    
167     /* dev_dec21052_init() */
168     int dev_dec21052_init(struct pci_bus *pci_bus,int pci_device,
169     struct pci_bus *sec_bus);
170    
171     /* dev_dec21150_init() */
172     int dev_dec21150_init(struct pci_bus *pci_bus,int pci_device,
173     struct pci_bus *sec_bus);
174    
175     /* dev_dec21152_init() */
176     int dev_dec21152_init(struct pci_bus *pci_bus,int pci_device,
177     struct pci_bus *sec_bus);
178    
179 dpavlin 7 /* dev_dec21154_init() */
180     int dev_dec21154_init(struct pci_bus *pci_bus,int pci_device,
181     struct pci_bus *sec_bus);
182    
183 dpavlin 1 /* dev_pericom_init() */
184     int dev_pericom_init(struct pci_bus *pci_bus,int pci_device,
185     struct pci_bus *sec_bus);
186    
187 dpavlin 4 /* dev_ti2050b_init() */
188     int dev_ti2050b_init(struct pci_bus *pci_bus,int pci_device,
189     struct pci_bus *sec_bus);
190    
191 dpavlin 1 /* Create an AP1011 Sturgeon HyperTransport-PCI Bridge */
192     int dev_ap1011_init(struct pci_bus *pci_bus,int pci_device,
193     struct pci_bus *sec_bus);
194    
195 dpavlin 7 /* dev_plx6520cb_init() */
196     int dev_plx6520cb_init(struct pci_bus *pci_bus,int pci_device,
197     struct pci_bus *sec_bus);
198    
199 dpavlin 1 /* dev_clpd6729_init() */
200     int dev_clpd6729_init(vm_instance_t *vm,
201     struct pci_bus *pci_bus,int pci_device,
202     struct pci_io_data *pci_io_data,
203     m_uint32_t io_start,m_uint32_t io_end);
204    
205     /* Create a NS16552 device */
206     int dev_ns16552_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len,
207 dpavlin 2 u_int reg_div,u_int irq,vtty_t *vtty_A,vtty_t *vtty_B);
208 dpavlin 1
209     /* Initialize an SRAM device */
210     int dev_c7200_sram_init(vm_instance_t *vm,char *name,
211     m_uint64_t paddr,m_uint32_t len,
212     struct pci_bus *pci_bus,int pci_device);
213    
214     /* Initialize a PCMCIA disk */
215     vm_obj_t *dev_pcmcia_disk_init(vm_instance_t *vm,char *name,
216     m_uint64_t paddr,m_uint32_t len,
217 dpavlin 4 u_int disk_size,int mode);
218 dpavlin 1
219 dpavlin 7 /* Get the device associated with a PCMCIA disk object */
220     struct vdevice *dev_pcmcia_disk_get_device(vm_obj_t *obj);
221    
222 dpavlin 1 /* Create SB-1 system control devices */
223     int dev_sb1_init(vm_instance_t *vm);
224    
225     /* Create SB-1 I/O devices */
226     int dev_sb1_io_init(vm_instance_t *vm,u_int duart_irq);
227    
228     /* Create the SB-1 PCI bus configuration zone */
229     int dev_sb1_pci_init(vm_instance_t *vm,char *name,m_uint64_t paddr);
230    
231     /* dev_sb1_duart_init() */
232     int dev_sb1_duart_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len);
233    
234     /* remote control device */
235     int dev_remote_control_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len);
236    
237     #endif

  ViewVC Help
Powered by ViewVC 1.1.26