/[dynamips]/upstream/dynamips-0.2.6-RC3/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 /upstream/dynamips-0.2.6-RC3/device.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (hide annotations)
Sat Oct 6 16:06:49 2007 UTC (14 years, 9 months ago) by dpavlin
File MIME type: text/plain
File size: 6906 byte(s)
dynamips-0.2.6-RC3

1 dpavlin 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     /* Get device by ID */
60     struct vdevice *dev_get_by_id(vm_instance_t *vm,u_int dev_id);
61    
62     /* Get device by name */
63     struct vdevice *dev_get_by_name(vm_instance_t *vm,char *name);
64    
65     /* Device lookup by physical address */
66     struct vdevice *dev_lookup(vm_instance_t *vm,m_uint64_t phys_addr,int cached);
67    
68     /* Find the next device after the specified address */
69     struct vdevice *dev_lookup_next(vm_instance_t *vm,m_uint64_t phys_addr,
70     struct vdevice *dev_start,int cached);
71    
72     /* Initialize a device */
73     void dev_init(struct vdevice *dev);
74    
75     /* Allocate a device */
76     struct vdevice *dev_create(char *name);
77    
78     /* Remove a device */
79     void dev_remove(vm_instance_t *vm,struct vdevice *dev);
80    
81     /* Show properties of a device */
82     void dev_show(struct vdevice *dev);
83    
84     /* Show the device list */
85     void dev_show_list(vm_instance_t *vm);
86    
87     /* device access function */
88     void *dev_access(cpu_mips_t *cpu,u_int dev_id,m_uint32_t offset,
89     u_int op_size,u_int op_type,m_uint64_t *data);
90    
91 dpavlin 4 /* Synchronize memory for a memory-mapped (mmap) device */
92     int dev_sync(struct vdevice *dev);
93    
94 dpavlin 1 /* Remap a device at specified physical address */
95     struct vdevice *dev_remap(char *name,struct vdevice *orig,
96     m_uint64_t paddr,m_uint32_t len);
97    
98     /* Create a RAM device */
99     struct vdevice *dev_create_ram(vm_instance_t *vm,char *name,char *filename,
100     m_uint64_t paddr,m_uint32_t len);
101    
102 dpavlin 4 /* Create a ghosted RAM device */
103     struct vdevice *
104     dev_create_ghost_ram(vm_instance_t *vm,char *name,char *filename,
105     m_uint64_t paddr,m_uint32_t len);
106    
107 dpavlin 1 /* Create a memory alias */
108     struct vdevice *dev_create_ram_alias(vm_instance_t *vm,char *name,char *orig,
109     m_uint64_t paddr,m_uint32_t len);
110    
111     /* Create a dummy console */
112     int dev_create_dummy_console(vm_instance_t *vm);
113    
114     /* Initialized a zeroed memory zone */
115     int dev_zero_init(vm_instance_t *vm,char *name,
116     m_uint64_t paddr,m_uint32_t len);
117    
118     /* Initialize a RAM zone */
119 dpavlin 4 int dev_ram_init(vm_instance_t *vm,char *name,int use_mmap,int delete_file,
120     char *alternate_name,m_uint64_t paddr,m_uint32_t len);
121 dpavlin 1
122 dpavlin 4 /* Initialize a ghosted RAM zone */
123     int dev_ram_ghost_init(vm_instance_t *vm,char *name,char *filename,
124     m_uint64_t paddr,m_uint32_t len);
125    
126 dpavlin 1 /* Initialize a ROM zone */
127     int dev_rom_init(vm_instance_t *vm,char *name,m_uint64_t paddr,m_uint32_t len);
128    
129     /* Create the NVRAM device */
130     int dev_nvram_init(vm_instance_t *vm,char *name,
131     m_uint64_t paddr,m_uint32_t len,
132     u_int *conf_reg);
133    
134     /* Create a 8 Mb bootflash */
135     int dev_bootflash_init(vm_instance_t *vm,char *name,
136     m_uint64_t paddr,m_uint32_t len);
137    
138 dpavlin 4 /* Create a Flash device */
139     vm_obj_t *dev_flash_init(vm_instance_t *vm,char *name,
140     m_uint64_t paddr,m_uint32_t len);
141 dpavlin 1
142 dpavlin 4 /* Copy data directly to a flash device */
143     int dev_flash_copy_data(vm_obj_t *obj,m_uint32_t offset,
144     u_char *ptr,ssize_t len);
145 dpavlin 1
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 dpavlin 4 /* dev_ti2050b_init() */
167     int dev_ti2050b_init(struct pci_bus *pci_bus,int pci_device,
168     struct pci_bus *sec_bus);
169    
170 dpavlin 1 /* Create an AP1011 Sturgeon HyperTransport-PCI Bridge */
171     int dev_ap1011_init(struct pci_bus *pci_bus,int pci_device,
172     struct pci_bus *sec_bus);
173    
174     /* dev_clpd6729_init() */
175     int dev_clpd6729_init(vm_instance_t *vm,
176     struct pci_bus *pci_bus,int pci_device,
177     struct pci_io_data *pci_io_data,
178     m_uint32_t io_start,m_uint32_t io_end);
179    
180     /* Create a NS16552 device */
181     int dev_ns16552_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len,
182 dpavlin 2 u_int reg_div,u_int irq,vtty_t *vtty_A,vtty_t *vtty_B);
183 dpavlin 1
184     /* Initialize an SRAM device */
185     int dev_c7200_sram_init(vm_instance_t *vm,char *name,
186     m_uint64_t paddr,m_uint32_t len,
187     struct pci_bus *pci_bus,int pci_device);
188    
189     /* Initialize a PCMCIA disk */
190     vm_obj_t *dev_pcmcia_disk_init(vm_instance_t *vm,char *name,
191     m_uint64_t paddr,m_uint32_t len,
192 dpavlin 4 u_int disk_size,int mode);
193 dpavlin 1
194     /* Create SB-1 system control devices */
195     int dev_sb1_init(vm_instance_t *vm);
196    
197     /* Create SB-1 I/O devices */
198     int dev_sb1_io_init(vm_instance_t *vm,u_int duart_irq);
199    
200     /* Create the SB-1 PCI bus configuration zone */
201     int dev_sb1_pci_init(vm_instance_t *vm,char *name,m_uint64_t paddr);
202    
203     /* dev_sb1_duart_init() */
204     int dev_sb1_duart_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len);
205    
206     /* remote control device */
207     int dev_remote_control_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len);
208    
209     #endif

  ViewVC Help
Powered by ViewVC 1.1.26