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

Diff of /trunk/vm.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

upstream/dynamips-0.2.6-RC1/vm.h revision 2 by dpavlin, Sat Oct 6 16:03:58 2007 UTC upstream/dynamips-0.2.7-RC3/vm.h revision 9 by dpavlin, Sat Oct 6 16:26:06 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   * Cisco 7200 (Predator) simulation platform.   * Cisco router simulation platform.
3   * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)   * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)
4   *   *
5   * Virtual Machines.   * Virtual Machines.
# Line 10  Line 10 
10    
11  #include <pthread.h>  #include <pthread.h>
12    
 #include "mips64.h"  
13  #include "dynamips.h"  #include "dynamips.h"
14  #include "memory.h"  #include "memory.h"
15  #include "cpu.h"  #include "cpu.h"
16  #include "dev_vtty.h"  #include "dev_vtty.h"
17    
18    #define VM_PAGE_SHIFT  12
19    #define VM_PAGE_SIZE   (1 << VM_PAGE_SHIFT)
20    #define VM_PAGE_IMASK  (VM_PAGE_SIZE - 1)
21    #define VM_PAGE_MASK   (~(VM_PAGE_IMASK))
22    
23    /* Number of pages in chunk area */
24    #define VM_CHUNK_AREA_SIZE  256
25    
26    /* VM memory chunk */
27    typedef struct vm_chunk vm_chunk_t;
28    struct vm_chunk {
29       void *area;
30       u_int page_alloc,page_total;
31       vm_chunk_t *next;
32    };
33    
34    /* VM ghost pool entry */
35    typedef struct vm_ghost_image vm_ghost_image_t;
36    struct vm_ghost_image {
37       char *filename;
38       u_int ref_count;
39       int fd;
40       off_t file_size;
41       u_char *area_ptr;
42       vm_ghost_image_t *next;
43    };
44    
45    /* Maximum number of devices per VM */
46    #define VM_DEVICE_MAX  (1 << 6)
47    
48    /* Size of the PCI bus pool */
49  #define VM_PCI_POOL_SIZE  32  #define VM_PCI_POOL_SIZE  32
50    
51  /* VM instance status */  /* VM instance status */
# Line 30  enum { Line 60  enum {
60  enum {  enum {
61     VM_TYPE_C7200 = 0,     VM_TYPE_C7200 = 0,
62     VM_TYPE_C3600,     VM_TYPE_C3600,
63       VM_TYPE_C2691,
64       VM_TYPE_C3725,
65       VM_TYPE_C3745,
66       VM_TYPE_C2600,
67       VM_TYPE_MSFC1,
68       VM_TYPE_PPC32_TEST,
69    };
70    
71    /* Ghost RAM status */
72    enum {
73       VM_GHOST_RAM_NONE = 0,
74       VM_GHOST_RAM_GENERATE,
75       VM_GHOST_RAM_USE,
76  };  };
77    
78  /* Timer IRQ check interval */  /* Timer IRQ check interval */
# Line 56  struct vm_instance { Line 99  struct vm_instance {
99     int status;                     /* Instance status */     int status;                     /* Instance status */
100     int instance_id;                /* Instance Identifier */     int instance_id;                /* Instance Identifier */
101     char *lock_file;                /* Lock file */     char *lock_file;                /* Lock file */
102     char *log_file;                 /* Log file */     char *log_file;                 /* Log filename */
103       int log_file_enabled;           /* Logging enabled */
104     u_int ram_size,rom_size;        /* RAM and ROM size in Mb */     u_int ram_size,rom_size;        /* RAM and ROM size in Mb */
105     u_int iomem_size;               /* IOMEM size in Mb */     u_int iomem_size;               /* IOMEM size in Mb */
106     u_int nvram_size;               /* NVRAM size in Kb */     u_int nvram_size;               /* NVRAM size in Kb */
# Line 75  struct vm_instance { Line 119  struct vm_instance {
119     FILE *lock_fd,*log_fd;          /* Lock/Log file descriptors */     FILE *lock_fd,*log_fd;          /* Lock/Log file descriptors */
120     int debug_level;                /* Debugging Level */     int debug_level;                /* Debugging Level */
121     int jit_use;                    /* CPUs use JIT */     int jit_use;                    /* CPUs use JIT */
122       int sparse_mem;                 /* Use sparse virtual memory */
123    
124       /* Memory chunks */
125       vm_chunk_t *chunks;
126    
127     /* Basic hardware: system CPU, PCI busses and PCI I/O space */     /* Basic hardware: system CPU, PCI busses and PCI I/O space */
128     cpu_group_t *cpu_group;     cpu_group_t *cpu_group;
129     cpu_mips_t *boot_cpu;     cpu_gen_t *boot_cpu;
130     struct pci_bus *pci_bus[2];     struct pci_bus *pci_bus[2];
131     struct pci_bus *pci_bus_pool[VM_PCI_POOL_SIZE];     struct pci_bus *pci_bus_pool[VM_PCI_POOL_SIZE];
132     struct pci_io_data *pci_io_space;     struct pci_io_data *pci_io_space;
133    
134     /* Memory mapped devices */     /* Memory mapped devices */
135     struct vdevice *dev_list;     struct vdevice *dev_list;
136     struct vdevice *dev_array[MIPS64_DEVICE_MAX];     struct vdevice *dev_array[VM_DEVICE_MAX];
137    
138     /* "idling" pointer counter */     /* IRQ routing */
139     m_uint64_t idle_pc;     void (*set_irq)(vm_instance_t *vm,u_int irq);
140       void (*clear_irq)(vm_instance_t *vm,u_int irq);
141    
142       /* Filename for ghosted RAM */
143       char *ghost_ram_filename;
144      
145       /* Ghost RAM image handling */
146       int ghost_status;
147    
148     /* Timer IRQ interval check */     /* Timer IRQ interval check */
149     u_int timer_irq_check_itv;     u_int timer_irq_check_itv;
150    
151       /* "idling" pointer counter */
152       m_uint64_t idle_pc;
153    
154       /* JIT block direct jumps */
155       int exec_blk_direct_jump;
156    
157       /* IRQ idling preemption */
158       u_int irq_idle_preempt[256];
159    
160     /* Console and AUX port VTTY type and parameters */     /* Console and AUX port VTTY type and parameters */
161     int vtty_con_type,vtty_aux_type;     int vtty_con_type,vtty_aux_type;
162     int vtty_con_tcp_port,vtty_aux_tcp_port;     int vtty_con_tcp_port,vtty_aux_tcp_port;
# Line 108  struct vm_instance { Line 172  struct vm_instance {
172     ssize_t (*nvram_extract_config)(vm_instance_t *vm,char **buffer);     ssize_t (*nvram_extract_config)(vm_instance_t *vm,char **buffer);
173     int (*nvram_push_config)(vm_instance_t *vm,char *buffer,size_t len);     int (*nvram_push_config)(vm_instance_t *vm,char *buffer,size_t len);
174    
175       /* Chassis cookie (for c2600 and maybe other routers) */
176       m_uint16_t chassis_cookie[64];
177    
178     /* Specific hardware data */     /* Specific hardware data */
179     void *hw_data;     void *hw_data;
180    
# Line 117  struct vm_instance { Line 184  struct vm_instance {
184    
185  #define VM_C7200(vm) ((c7200_t *)vm->hw_data)  #define VM_C7200(vm) ((c7200_t *)vm->hw_data)
186  #define VM_C3600(vm) ((c3600_t *)vm->hw_data)  #define VM_C3600(vm) ((c3600_t *)vm->hw_data)
187    #define VM_C2691(vm) ((c2691_t *)vm->hw_data)
188    #define VM_C3725(vm) ((c3725_t *)vm->hw_data)
189    #define VM_C3745(vm) ((c3745_t *)vm->hw_data)
190    #define VM_C2600(vm) ((c2600_t *)vm->hw_data)
191    #define VM_MSFC1(vm) ((msfc1_t *)vm->hw_data)
192    
193  extern int vm_file_naming_type;  extern int vm_file_naming_type;
194    
195    /* Set an IRQ for a VM */
196    static inline void vm_set_irq(vm_instance_t *vm,u_int irq)
197    {
198       if (vm->set_irq != NULL)
199          vm->set_irq(vm,irq);
200    }
201    
202    /* Clear an IRQ for a VM */
203    static inline void vm_clear_irq(vm_instance_t *vm,u_int irq)
204    {
205       if (vm->clear_irq != NULL)
206          vm->clear_irq(vm,irq);
207    }
208    
209  /* Initialize a VM object */  /* Initialize a VM object */
210  void vm_object_init(vm_obj_t *obj);  void vm_object_init(vm_obj_t *obj);
211    
# Line 141  void vm_object_dump(vm_instance_t *vm); Line 227  void vm_object_dump(vm_instance_t *vm);
227  /* Get VM type */  /* Get VM type */
228  char *vm_get_type(vm_instance_t *vm);  char *vm_get_type(vm_instance_t *vm);
229    
230    /* Get MAC address MSB */
231    u_int vm_get_mac_addr_msb(vm_instance_t *vm);
232    
233  /* Generate a filename for use by the instance */  /* Generate a filename for use by the instance */
234  char *vm_build_filename(vm_instance_t *vm,char *name);  char *vm_build_filename(vm_instance_t *vm,char *name);
235    
# Line 180  vm_instance_t *vm_acquire(char *name); Line 269  vm_instance_t *vm_acquire(char *name);
269  /* Release a VM (decrement reference count) */  /* Release a VM (decrement reference count) */
270  int vm_release(vm_instance_t *vm);  int vm_release(vm_instance_t *vm);
271    
272    /* Initialize RAM */
273    int vm_ram_init(vm_instance_t *vm,m_uint64_t paddr);
274    
275  /* Initialize VTTY */  /* Initialize VTTY */
276  int vm_init_vtty(vm_instance_t *vm);  int vm_init_vtty(vm_instance_t *vm);
277    
# Line 213  int vm_stop(vm_instance_t *vm); Line 305  int vm_stop(vm_instance_t *vm);
305  /* Monitor an instance periodically */  /* Monitor an instance periodically */
306  void vm_monitor(vm_instance_t *vm);  void vm_monitor(vm_instance_t *vm);
307    
308    /* Allocate an host page */
309    void *vm_alloc_host_page(vm_instance_t *vm);
310    
311    /* Free an host page */
312    void vm_free_host_page(vm_instance_t *vm,void *ptr);
313    
314    /* Get a ghost image */
315    int vm_ghost_image_get(char *filename,u_char **ptr,int *fd);
316    
317    /* Release a ghost image */
318    int vm_ghost_image_release(int fd);
319    
320    /* Open a VM file and map it in memory */
321    int vm_mmap_open_file(vm_instance_t *vm,char *name,
322                          u_char **ptr,off_t *fsize);
323    
324    /* Open/Create a VM file and map it in memory */
325    int vm_mmap_create_file(vm_instance_t *vm,char *name,size_t len,u_char **ptr);
326    
327    /* Close a memory mapped file */
328    int vm_mmap_close_file(int fd,u_char *ptr,size_t len);
329    
330  /* Save the Cisco IOS configuration from NVRAM */  /* Save the Cisco IOS configuration from NVRAM */
331  int vm_ios_save_config(vm_instance_t *vm);  int vm_ios_save_config(vm_instance_t *vm);
332    

Legend:
Removed from v.2  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26