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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (hide annotations)
Sat Oct 6 16:23:47 2007 UTC (16 years, 6 months ago) by dpavlin
Original Path: upstream/dynamips-0.2.7-RC1/dev_c2600_pci.c
File MIME type: text/plain
File size: 2676 byte(s)
dynamips-0.2.7-RC1

1 dpavlin 7 /*
2     * Cisco router simulation platform.
3     * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)
4     *
5     * Cisco 2600 PCI controller.
6     */
7    
8     #include <stdio.h>
9     #include <stdlib.h>
10     #include <string.h>
11    
12     #include "utils.h"
13     #include "net.h"
14     #include "cpu.h"
15     #include "vm.h"
16     #include "dynamips.h"
17     #include "memory.h"
18     #include "device.h"
19     #include "net_io.h"
20    
21     /* Debugging flags */
22     #define DEBUG_ACCESS 0
23     #define DEBUG_UNKNOWN 1
24    
25     /* Galileo GT64xxx/GT96xxx system controller */
26     struct c2600_pci_data {
27     char *name;
28     vm_obj_t vm_obj;
29     struct vdevice dev;
30     struct pci_device *pci_dev;
31     vm_instance_t *vm;
32    
33     struct pci_bus *bus;
34     };
35    
36     /*
37     * dev_c2600_pci_access()
38     */
39     void *dev_c2600_pci_access(cpu_gen_t *cpu,struct vdevice *dev,
40     m_uint32_t offset,u_int op_size,u_int op_type,
41     m_uint64_t *data)
42     {
43     struct c2600_pci_data *d = dev->priv_data;
44    
45     if (op_type == MTS_READ)
46     *data = 0x0;
47    
48     switch(offset) {
49     case 0x500:
50     pci_dev_addr_handler(cpu,d->bus,op_type,FALSE,data);
51     break;
52    
53     case 0x504:
54     pci_dev_data_handler(cpu,d->bus,op_type,FALSE,data);
55     break;
56    
57     #if DEBUG_UNKNOWN
58     default:
59     if (op_type == MTS_READ) {
60     cpu_log(cpu,d->name,"read from addr 0x%x, pc=0x%llx\n",
61     offset,cpu_get_pc(cpu));
62     } else {
63     cpu_log(cpu,d->name,"write to addr 0x%x, value=0x%llx, "
64     "pc=0x%llx\n",offset,*data,cpu_get_pc(cpu));
65     }
66     #endif
67     }
68    
69     return NULL;
70     }
71    
72     /* Shutdown the c2600 PCI controller device */
73     void dev_c2600_pci_shutdown(vm_instance_t *vm,struct c2600_pci_data *d)
74     {
75     if (d != NULL) {
76     /* Remove the device */
77     dev_remove(vm,&d->dev);
78    
79     /* Free the structure itself */
80     free(d);
81     }
82     }
83    
84     /* Create the c2600 PCI controller device */
85     int dev_c2600_pci_init(vm_instance_t *vm,char *name,
86     m_uint64_t paddr,m_uint32_t len,
87     struct pci_bus *bus)
88     {
89     struct c2600_pci_data *d;
90    
91     if (!(d = malloc(sizeof(*d)))) {
92     fprintf(stderr,"c2600_pci: unable to create device data.\n");
93     return(-1);
94     }
95    
96     memset(d,0,sizeof(*d));
97     d->name = name;
98     d->vm = vm;
99     d->bus = bus;
100    
101     vm_object_init(&d->vm_obj);
102     d->vm_obj.name = name;
103     d->vm_obj.data = d;
104     d->vm_obj.shutdown = (vm_shutdown_t)dev_c2600_pci_shutdown;
105    
106     dev_init(&d->dev);
107     d->dev.name = name;
108     d->dev.priv_data = d;
109     d->dev.phys_addr = paddr;
110     d->dev.phys_len = len;
111     d->dev.handler = dev_c2600_pci_access;
112    
113     /* Map this device to the VM */
114     vm_bind_device(vm,&d->dev);
115     vm_object_add(vm,&d->vm_obj);
116     return(0);
117     }
118    

  ViewVC Help
Powered by ViewVC 1.1.26