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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Sat Oct 6 16:01:44 2007 UTC (14 years, 9 months ago) by dpavlin
Original Path: upstream/dynamips-0.2.5/dev_sb1.c
File MIME type: text/plain
File size: 2477 byte(s)
import 0.2.5 from upstream

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

  ViewVC Help
Powered by ViewVC 1.1.26