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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (hide annotations)
Sat Oct 6 16:45:40 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 2496 byte(s)
make working copy

1 dpavlin 1 /*
2 dpavlin 7 * Cisco router simulation platform.
3 dpavlin 1 * Copyright (c) 2005 Christophe Fillot (cf@utc.fr)
4     *
5     * SB-1 system control devices.
6     */
7    
8     #include <stdio.h>
9     #include <stdlib.h>
10     #include <string.h>
11     #include <unistd.h>
12     #include <sys/types.h>
13    
14     #include <termios.h>
15     #include <fcntl.h>
16     #include <pthread.h>
17    
18 dpavlin 7 #include "cpu.h"
19     #include "vm.h"
20 dpavlin 1 #include "dynamips.h"
21     #include "memory.h"
22     #include "device.h"
23     #include "dev_c7200.h"
24    
25     #define DEBUG_UNKNOWN 1
26    
27     /* SB-1 private data */
28     struct sb1_data {
29     vm_obj_t vm_obj;
30     struct vdevice dev;
31    
32     /* Virtual machine */
33     vm_instance_t *vm;
34     };
35    
36     /*
37     * dev_sb1_access()
38     */
39 dpavlin 7 void *dev_sb1_access(cpu_gen_t *cpu,struct vdevice *dev,
40 dpavlin 1 m_uint32_t offset,u_int op_size,u_int op_type,
41     m_uint64_t *data)
42     {
43     struct sb1_data *d = dev->priv_data;
44    
45     if (op_type == MTS_READ)
46     *data = 0;
47    
48     switch(offset) {
49     case 0x20000:
50     if (op_type == MTS_READ)
51     *data = 0x125020FF;
52     break;
53    
54     /* Seen on a real NPE-G1 :) */
55     case 0x20008:
56     if (op_type == MTS_READ)
57     *data = 0x00800000FCDB0700ULL;
58     break;
59    
60     #if DEBUG_UNKNOWN
61     default:
62     if (op_type == MTS_READ) {
63     cpu_log(cpu,"SB1","read from addr 0x%x, pc=0x%llx\n",
64 dpavlin 7 offset,cpu_get_pc(cpu));
65 dpavlin 1 } else {
66     cpu_log(cpu,"SB1","write to addr 0x%x, value=0x%llx, pc=0x%llx\n",
67 dpavlin 7 offset,*data,cpu_get_pc(cpu));
68 dpavlin 1 }
69     #endif
70     }
71    
72     return NULL;
73     }
74    
75     /* Shutdown the SB-1 system control devices */
76     void dev_sb1_shutdown(vm_instance_t *vm,struct sb1_data *d)
77     {
78     if (d != NULL) {
79     /* Remove the device */
80     dev_remove(vm,&d->dev);
81    
82     /* Free the structure itself */
83     free(d);
84     }
85     }
86    
87    
88     /* Create SB-1 system control devices */
89     int dev_sb1_init(vm_instance_t *vm)
90     {
91     struct sb1_data *d;
92    
93     /* allocate private data structure */
94     if (!(d = malloc(sizeof(*d)))) {
95     fprintf(stderr,"SB1: out of memory\n");
96     return(-1);
97     }
98    
99     memset(d,0,sizeof(*d));
100    
101     vm_object_init(&d->vm_obj);
102     d->vm_obj.name = "sb1_sysctrl";
103     d->vm_obj.data = d;
104     d->vm_obj.shutdown = (vm_shutdown_t)dev_sb1_shutdown;
105    
106     dev_init(&d->dev);
107     d->dev.name = "sb1_sysctrl";
108     d->dev.priv_data = d;
109     d->dev.phys_addr = 0x10000000ULL;
110     d->dev.phys_len = 0x60000;
111     d->dev.handler = dev_sb1_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     }

  ViewVC Help
Powered by ViewVC 1.1.26