/[dynamips]/upstream/dynamips-0.2.5/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

Contents of /upstream/dynamips-0.2.5/device.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Sat Oct 6 16:01:44 2007 UTC (12 years, 2 months ago) by dpavlin
File MIME type: text/plain
File size: 6705 byte(s)
import 0.2.5 from upstream

1 /*
2 * Cisco 7200 (Predator) simulation platform.
3 * 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 "mips64.h"
12 #include "cpu.h"
13 #include "net_io.h"
14 #include "vm.h"
15
16 /* Device Flags */
17 #define VDEVICE_FLAG_NO_MTS_MMAP 0x01 /* Prevent MMAPed access by MTS */
18 #define VDEVICE_FLAG_CACHING 0x02 /* Device does support caching */
19 #define VDEVICE_FLAG_REMAP 0x04 /* Physical address remapping */
20 #define VDEVICE_FLAG_SYNC 0x08 /* Forced sync */
21
22 typedef void *(*dev_handler_t)(cpu_mips_t *cpu,struct vdevice *dev,
23 m_uint32_t offset,u_int op_size,u_int op_type,
24 m_uint64_t *data);
25
26 /* Virtual Device */
27 struct vdevice {
28 char *name;
29 u_int id;
30 m_uint64_t phys_addr;
31 m_uint32_t phys_len;
32 m_iptr_t host_addr;
33 void *priv_data;
34 int flags;
35 int fd;
36 dev_handler_t handler;
37 struct vdevice *next,**pprev;
38 };
39
40 /* PCI part */
41 #include "pci_dev.h"
42
43 /* device access function */
44 static forced_inline
45 void *dev_access_fast(cpu_mips_t *cpu,u_int dev_id,m_uint32_t offset,
46 u_int op_size,u_int op_type,m_uint64_t *data)
47 {
48 struct vdevice *dev = cpu->vm->dev_array[dev_id];
49
50 if (unlikely(!dev)) {
51 cpu_log(cpu,"dev_access_fast","null handler (dev_id=%u,offset=0x%x)\n",
52 dev_id,offset);
53 return NULL;
54 }
55
56 return(dev->handler(cpu,dev,offset,op_size,op_type,data));
57 }
58
59
60 /* Map a memory zone from a file */
61 u_char *memzone_map_file(int fd,size_t len);
62
63 /* Create a file to serve as a memory zone */
64 int memzone_create_file(char *filename,size_t len,u_char **ptr);
65
66 /* Get device by ID */
67 struct vdevice *dev_get_by_id(vm_instance_t *vm,u_int dev_id);
68
69 /* Get device by name */
70 struct vdevice *dev_get_by_name(vm_instance_t *vm,char *name);
71
72 /* Device lookup by physical address */
73 struct vdevice *dev_lookup(vm_instance_t *vm,m_uint64_t phys_addr,int cached);
74
75 /* Find the next device after the specified address */
76 struct vdevice *dev_lookup_next(vm_instance_t *vm,m_uint64_t phys_addr,
77 struct vdevice *dev_start,int cached);
78
79 /* Initialize a device */
80 void dev_init(struct vdevice *dev);
81
82 /* Allocate a device */
83 struct vdevice *dev_create(char *name);
84
85 /* Remove a device */
86 void dev_remove(vm_instance_t *vm,struct vdevice *dev);
87
88 /* Show properties of a device */
89 void dev_show(struct vdevice *dev);
90
91 /* Show the device list */
92 void dev_show_list(vm_instance_t *vm);
93
94 /* device access function */
95 void *dev_access(cpu_mips_t *cpu,u_int dev_id,m_uint32_t offset,
96 u_int op_size,u_int op_type,m_uint64_t *data);
97
98 /* 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 struct vdevice *dev_create_ram(vm_instance_t *vm,char *name,char *filename,
104 m_uint64_t paddr,m_uint32_t len);
105
106 /* Create a memory alias */
107 struct vdevice *dev_create_ram_alias(vm_instance_t *vm,char *name,char *orig,
108 m_uint64_t paddr,m_uint32_t len);
109
110 /* Create a dummy console */
111 int dev_create_dummy_console(vm_instance_t *vm);
112
113 /* Initialized a zeroed memory zone */
114 int dev_zero_init(vm_instance_t *vm,char *name,
115 m_uint64_t paddr,m_uint32_t len);
116
117 /* Initialize a RAM zone */
118 int dev_ram_init(vm_instance_t *vm,char *name,int use_mmap,
119 m_uint64_t paddr,m_uint32_t len);
120
121 /* Initialize a ROM zone */
122 int dev_rom_init(vm_instance_t *vm,char *name,m_uint64_t paddr,m_uint32_t len);
123
124 /* Create the NVRAM device */
125 int dev_nvram_init(vm_instance_t *vm,char *name,
126 m_uint64_t paddr,m_uint32_t len,
127 u_int *conf_reg);
128
129 /* Create a 8 Mb bootflash */
130 int dev_bootflash_init(vm_instance_t *vm,char *name,
131 m_uint64_t paddr,m_uint32_t len);
132
133 /* Create a PLX9060 device */
134 vm_obj_t *dev_plx9060_init(vm_instance_t *vm,char *name,
135 struct pci_bus *pci_bus,int pci_device,
136 struct vdevice *dev);
137
138 /* Create a new GT64010 controller */
139 int dev_gt64010_init(vm_instance_t *vm,char *name,
140 m_uint64_t paddr,m_uint32_t len,u_int irq);
141
142 /* Create a new GT64120 controller */
143 int dev_gt64120_init(vm_instance_t *vm,char *name,
144 m_uint64_t paddr,m_uint32_t len,u_int irq);
145
146 /* dev_dec21050_init() */
147 int dev_dec21050_init(struct pci_bus *pci_bus,int pci_device,
148 struct pci_bus *sec_bus);
149
150 /* dev_dec21052_init() */
151 int dev_dec21052_init(struct pci_bus *pci_bus,int pci_device,
152 struct pci_bus *sec_bus);
153
154 /* dev_dec21150_init() */
155 int dev_dec21150_init(struct pci_bus *pci_bus,int pci_device,
156 struct pci_bus *sec_bus);
157
158 /* dev_dec21152_init() */
159 int dev_dec21152_init(struct pci_bus *pci_bus,int pci_device,
160 struct pci_bus *sec_bus);
161
162 /* dev_pericom_init() */
163 int dev_pericom_init(struct pci_bus *pci_bus,int pci_device,
164 struct pci_bus *sec_bus);
165
166 /* Create an AP1011 Sturgeon HyperTransport-PCI Bridge */
167 int dev_ap1011_init(struct pci_bus *pci_bus,int pci_device,
168 struct pci_bus *sec_bus);
169
170 /* dev_clpd6729_init() */
171 int dev_clpd6729_init(vm_instance_t *vm,
172 struct pci_bus *pci_bus,int pci_device,
173 struct pci_io_data *pci_io_data,
174 m_uint32_t io_start,m_uint32_t io_end);
175
176 /* Create a NS16552 device */
177 int dev_ns16552_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len,
178 u_int irq,vtty_t *vtty_portA,vtty_t *vtty_portB);
179
180 /* Initialize an SRAM device */
181 int dev_c7200_sram_init(vm_instance_t *vm,char *name,
182 m_uint64_t paddr,m_uint32_t len,
183 struct pci_bus *pci_bus,int pci_device);
184
185 /* Initialize a PCMCIA disk */
186 vm_obj_t *dev_pcmcia_disk_init(vm_instance_t *vm,char *name,
187 m_uint64_t paddr,m_uint32_t len,
188 u_int disk_size);
189
190 /* Create SB-1 system control devices */
191 int dev_sb1_init(vm_instance_t *vm);
192
193 /* Create SB-1 I/O devices */
194 int dev_sb1_io_init(vm_instance_t *vm,u_int duart_irq);
195
196 /* Create the SB-1 PCI bus configuration zone */
197 int dev_sb1_pci_init(vm_instance_t *vm,char *name,m_uint64_t paddr);
198
199 /* dev_sb1_duart_init() */
200 int dev_sb1_duart_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len);
201
202 /* remote control device */
203 int dev_remote_control_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len);
204
205 #endif

  ViewVC Help
Powered by ViewVC 1.1.26