/[dynamips]/upstream/dynamips-0.2.5/vm.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/vm.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: 7072 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 * Virtual Machines.
6 */
7
8 #ifndef __VM_H__
9 #define __VM_H__
10
11 #include <pthread.h>
12
13 #include "mips64.h"
14 #include "dynamips.h"
15 #include "memory.h"
16 #include "cpu.h"
17 #include "dev_vtty.h"
18
19 #define VM_PCI_POOL_SIZE 32
20
21 /* VM instance status */
22 enum {
23 VM_STATUS_HALTED = 0, /* VM is halted and no HW resources are used */
24 VM_STATUS_SHUTDOWN, /* Shutdown procedure engaged */
25 VM_STATUS_RUNNING, /* VM is running */
26 VM_STATUS_SUSPENDED, /* VM is suspended */
27 };
28
29 /* VM types */
30 enum {
31 VM_TYPE_C7200 = 0,
32 VM_TYPE_C3600,
33 };
34
35 /* Timer IRQ check interval */
36 #define VM_TIMER_IRQ_CHECK_ITV 1000
37
38 /* forward declarations */
39 typedef struct vm_obj vm_obj_t;
40
41 /* Shutdown function prototype for an object */
42 typedef void *(*vm_shutdown_t)(vm_instance_t *vm,void *data);
43
44 /* VM object, used to keep track of devices and various things */
45 struct vm_obj {
46 char *name;
47 void *data;
48 struct vm_obj *next,**pprev;
49 vm_shutdown_t shutdown;
50 };
51
52 /* VM instance */
53 struct vm_instance {
54 char *name;
55 int type; /* C7200, C3600, ... */
56 int status; /* Instance status */
57 int instance_id; /* Instance Identifier */
58 char *lock_file; /* Lock file */
59 char *log_file; /* Log file */
60 u_int ram_size,rom_size; /* RAM and ROM size in Mb */
61 u_int iomem_size; /* IOMEM size in Mb */
62 u_int nvram_size; /* NVRAM size in Kb */
63 u_int pcmcia_disk_size[2]; /* PCMCIA disk0 and disk1 sizes (in Mb) */
64 u_int conf_reg,conf_reg_setup; /* Config register */
65 u_int clock_divisor; /* Clock Divisor (see cp0.c) */
66 u_int ram_mmap; /* Memory-mapped RAM ? */
67 u_int restart_ios; /* Restart IOS on reload ? */
68 u_int elf_machine_id; /* ELF machine identifier */
69 u_int exec_area_size; /* Size of execution area for CPU */
70 m_uint32_t ios_entry_point; /* IOS entry point */
71 char *ios_image; /* IOS image filename */
72 char *ios_config; /* IOS configuration file */
73 char *rom_filename; /* ROM filename */
74 char *sym_filename; /* Symbol filename */
75 FILE *lock_fd,*log_fd; /* Lock/Log file descriptors */
76 int debug_level; /* Debugging Level */
77 int jit_use; /* CPUs use JIT */
78
79 /* Basic hardware: system CPU, PCI busses and PCI I/O space */
80 cpu_group_t *cpu_group;
81 cpu_mips_t *boot_cpu;
82 struct pci_bus *pci_bus[2];
83 struct pci_bus *pci_bus_pool[VM_PCI_POOL_SIZE];
84 struct pci_io_data *pci_io_space;
85
86 /* Memory mapped devices */
87 struct vdevice *dev_list;
88 struct vdevice *dev_array[MIPS64_DEVICE_MAX];
89
90 /* "idling" pointer counter */
91 m_uint64_t idle_pc;
92
93 /* Timer IRQ interval check */
94 u_int timer_irq_check_itv;
95
96 /* Console and AUX port VTTY type and parameters */
97 int vtty_con_type,vtty_aux_type;
98 int vtty_con_tcp_port,vtty_aux_tcp_port;
99 vtty_serial_option_t vtty_con_serial_option,vtty_aux_serial_option;
100
101 /* Virtual TTY for Console and AUX ports */
102 vtty_t *vtty_con,*vtty_aux;
103
104 /* Space reserved in NVRAM by ROM monitor */
105 u_int nvram_rom_space;
106
107 /* Extract and push IOS configuration */
108 ssize_t (*nvram_extract_config)(vm_instance_t *vm,char **buffer);
109 int (*nvram_push_config)(vm_instance_t *vm,char *buffer,size_t len);
110
111 /* Specific hardware data */
112 void *hw_data;
113
114 /* VM objects */
115 struct vm_obj *vm_object_list;
116 };
117
118 #define VM_C7200(vm) ((c7200_t *)vm->hw_data)
119 #define VM_C3600(vm) ((c3600_t *)vm->hw_data)
120
121 extern int vm_file_naming_type;
122
123 /* Initialize a VM object */
124 void vm_object_init(vm_obj_t *obj);
125
126 /* Add a VM object to an instance */
127 void vm_object_add(vm_instance_t *vm,vm_obj_t *obj);
128
129 /* Remove a VM object from an instance */
130 void vm_object_remove(vm_instance_t *vm,vm_obj_t *obj);
131
132 /* Find an object given its name */
133 vm_obj_t *vm_object_find(vm_instance_t *vm,char *name);
134
135 /* Check that a mandatory object is present */
136 int vm_object_check(vm_instance_t *vm,char *name);
137
138 /* Dump the object list of an instance */
139 void vm_object_dump(vm_instance_t *vm);
140
141 /* Get VM type */
142 char *vm_get_type(vm_instance_t *vm);
143
144 /* Generate a filename for use by the instance */
145 char *vm_build_filename(vm_instance_t *vm,char *name);
146
147 /* Check that an instance lock file doesn't already exist */
148 int vm_get_lock(vm_instance_t *vm);
149
150 /* Erase lock file */
151 void vm_release_lock(vm_instance_t *vm,int erase);
152
153 /* Log a message */
154 void vm_flog(vm_instance_t *vm,char *module,char *format,va_list ap);
155
156 /* Log a message */
157 void vm_log(vm_instance_t *vm,char *module,char *format,...);
158
159 /* Close the log file */
160 int vm_close_log(vm_instance_t *vm);
161
162 /* Create the log file */
163 int vm_create_log(vm_instance_t *vm);
164
165 /* Error message */
166 void vm_error(vm_instance_t *vm,char *format,...);
167
168 /* Create a new VM instance */
169 vm_instance_t *vm_create(char *name,int instance_id,int machine_type);
170
171 /* Shutdown hardware resources used by a VM */
172 int vm_hardware_shutdown(vm_instance_t *vm);
173
174 /* Free resources used by a VM */
175 void vm_free(vm_instance_t *vm);
176
177 /* Get an instance given a name */
178 vm_instance_t *vm_acquire(char *name);
179
180 /* Release a VM (decrement reference count) */
181 int vm_release(vm_instance_t *vm);
182
183 /* Initialize VTTY */
184 int vm_init_vtty(vm_instance_t *vm);
185
186 /* Delete VTTY */
187 void vm_delete_vtty(vm_instance_t *vm);
188
189 /* Bind a device to a virtual machine */
190 int vm_bind_device(vm_instance_t *vm,struct vdevice *dev);
191
192 /* Unbind a device from a virtual machine */
193 int vm_unbind_device(vm_instance_t *vm,struct vdevice *dev);
194
195 /* Map a device at the specified physical address */
196 int vm_map_device(vm_instance_t *vm,struct vdevice *dev,m_uint64_t base_addr);
197
198 /* Set an IRQ for a VM */
199 void vm_set_irq(vm_instance_t *vm,u_int irq);
200
201 /* Clear an IRQ for a VM */
202 void vm_clear_irq(vm_instance_t *vm,u_int irq);
203
204 /* Suspend a VM instance */
205 int vm_suspend(vm_instance_t *vm);
206
207 /* Resume a VM instance */
208 int vm_resume(vm_instance_t *vm);
209
210 /* Stop an instance */
211 int vm_stop(vm_instance_t *vm);
212
213 /* Monitor an instance periodically */
214 void vm_monitor(vm_instance_t *vm);
215
216 /* Save the Cisco IOS configuration from NVRAM */
217 int vm_ios_save_config(vm_instance_t *vm);
218
219 /* Set Cisco IOS image to use */
220 int vm_ios_set_image(vm_instance_t *vm,char *ios_image);
221
222 /* Unset a Cisco IOS configuration file */
223 void vm_ios_unset_config(vm_instance_t *vm);
224
225 /* Set Cisco IOS configuration file to use */
226 int vm_ios_set_config(vm_instance_t *vm,char *ios_config);
227
228 /* Extract IOS configuration from NVRAM and write it to a file */
229 int vm_nvram_extract_config(vm_instance_t *vm,char *filename);
230
231 /* Read an IOS configuraton from a file and push it to NVRAM */
232 int vm_nvram_push_config(vm_instance_t *vm,char *filename);
233
234 /* Save general VM configuration into the specified file */
235 void vm_save_config(vm_instance_t *vm,FILE *fd);
236
237 #endif

  ViewVC Help
Powered by ViewVC 1.1.26