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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations)
Sat Oct 6 16:03:58 2007 UTC (14 years, 9 months ago) by dpavlin
Original Path: upstream/dynamips-0.2.6-RC1/device.h
File MIME type: text/plain
File size: 6813 byte(s)
import dynamips-0.2.6-RC1

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    
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 dpavlin 2 /* Compute NVRAM checksum */
130     m_uint16_t nvram_cksum(vm_instance_t *vm,m_uint64_t addr,size_t count);
131    
132 dpavlin 1 /* Create a 8 Mb bootflash */
133     int dev_bootflash_init(vm_instance_t *vm,char *name,
134     m_uint64_t paddr,m_uint32_t len);
135    
136     /* Create a PLX9060 device */
137     vm_obj_t *dev_plx9060_init(vm_instance_t *vm,char *name,
138     struct pci_bus *pci_bus,int pci_device,
139     struct vdevice *dev);
140    
141     /* Create a new GT64010 controller */
142     int dev_gt64010_init(vm_instance_t *vm,char *name,
143     m_uint64_t paddr,m_uint32_t len,u_int irq);
144    
145     /* Create a new GT64120 controller */
146     int dev_gt64120_init(vm_instance_t *vm,char *name,
147     m_uint64_t paddr,m_uint32_t len,u_int irq);
148    
149     /* dev_dec21050_init() */
150     int dev_dec21050_init(struct pci_bus *pci_bus,int pci_device,
151     struct pci_bus *sec_bus);
152    
153     /* dev_dec21052_init() */
154     int dev_dec21052_init(struct pci_bus *pci_bus,int pci_device,
155     struct pci_bus *sec_bus);
156    
157     /* dev_dec21150_init() */
158     int dev_dec21150_init(struct pci_bus *pci_bus,int pci_device,
159     struct pci_bus *sec_bus);
160    
161     /* dev_dec21152_init() */
162     int dev_dec21152_init(struct pci_bus *pci_bus,int pci_device,
163     struct pci_bus *sec_bus);
164    
165     /* dev_pericom_init() */
166     int dev_pericom_init(struct pci_bus *pci_bus,int pci_device,
167     struct pci_bus *sec_bus);
168    
169     /* Create an AP1011 Sturgeon HyperTransport-PCI Bridge */
170     int dev_ap1011_init(struct pci_bus *pci_bus,int pci_device,
171     struct pci_bus *sec_bus);
172    
173     /* dev_clpd6729_init() */
174     int dev_clpd6729_init(vm_instance_t *vm,
175     struct pci_bus *pci_bus,int pci_device,
176     struct pci_io_data *pci_io_data,
177     m_uint32_t io_start,m_uint32_t io_end);
178    
179     /* Create a NS16552 device */
180     int dev_ns16552_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len,
181 dpavlin 2 u_int reg_div,u_int irq,vtty_t *vtty_A,vtty_t *vtty_B);
182 dpavlin 1
183     /* Initialize an SRAM device */
184     int dev_c7200_sram_init(vm_instance_t *vm,char *name,
185     m_uint64_t paddr,m_uint32_t len,
186     struct pci_bus *pci_bus,int pci_device);
187    
188     /* Initialize a PCMCIA disk */
189     vm_obj_t *dev_pcmcia_disk_init(vm_instance_t *vm,char *name,
190     m_uint64_t paddr,m_uint32_t len,
191     u_int disk_size);
192    
193     /* Create SB-1 system control devices */
194     int dev_sb1_init(vm_instance_t *vm);
195    
196     /* Create SB-1 I/O devices */
197     int dev_sb1_io_init(vm_instance_t *vm,u_int duart_irq);
198    
199     /* Create the SB-1 PCI bus configuration zone */
200     int dev_sb1_pci_init(vm_instance_t *vm,char *name,m_uint64_t paddr);
201    
202     /* dev_sb1_duart_init() */
203     int dev_sb1_duart_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len);
204    
205     /* remote control device */
206     int dev_remote_control_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len);
207    
208     #endif

  ViewVC Help
Powered by ViewVC 1.1.26