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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations)
Sat Oct 6 16:05:34 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 1550 byte(s)
dynamips-0.2.6-RC2

1 dpavlin 1 /*
2     * Cisco C7200 (Predator) Simulation Platform.
3     * Copyright (C) 2005,2006 Christophe Fillot. All rights reserved.
4     *
5     * Zeroed memory zone.
6     */
7    
8     #include <stdio.h>
9     #include <stdlib.h>
10     #include <string.h>
11     #include <unistd.h>
12     #include <pthread.h>
13     #include <errno.h>
14    
15     #include "mips64.h"
16     #include "dynamips.h"
17     #include "memory.h"
18     #include "device.h"
19    
20     /* Zero zone private data */
21     struct zero_data {
22     vm_obj_t vm_obj;
23     struct vdevice dev;
24     };
25    
26     /*
27     * dev_zero_access()
28     */
29     void *dev_zero_access(cpu_mips_t *cpu,struct vdevice *dev,
30     m_uint32_t offset,u_int op_size,u_int op_type,
31     m_uint64_t *data)
32     {
33     if (op_type == MTS_READ)
34     *data = 0;
35    
36     return NULL;
37     }
38    
39     /* Shutdown a zeroed memory zone */
40     void dev_zero_shutdown(vm_instance_t *vm,struct zero_data *d)
41     {
42     if (d != NULL) {
43     dev_remove(vm,&d->dev);
44     free(d);
45     }
46     }
47    
48     /* Initialized a zeroed memory zone */
49     int dev_zero_init(vm_instance_t *vm,char *name,m_uint64_t paddr,m_uint32_t len)
50     {
51     struct zero_data *d;
52    
53     if (!(d = malloc(sizeof(*d)))) {
54     fprintf(stderr,"ZERO: unable to create device.\n");
55     return(-1);
56     }
57    
58     vm_object_init(&d->vm_obj);
59     d->vm_obj.name = name;
60     d->vm_obj.data = d;
61     d->vm_obj.shutdown = (vm_shutdown_t)dev_zero_shutdown;
62    
63     dev_init(&d->dev);
64     d->dev.name = name;
65     d->dev.phys_addr = paddr;
66     d->dev.phys_len = len;
67     d->dev.handler = dev_zero_access;
68    
69     /* Map this device to the VM */
70     vm_bind_device(vm,&d->dev);
71     vm_object_add(vm,&d->vm_obj);
72     return(0);
73     }

  ViewVC Help
Powered by ViewVC 1.1.26