1 |
/* |
/* |
2 |
* Cisco C7200 (Predator) RAM emulation |
* Cisco router simulation platform. |
3 |
* Copyright (c) 2006 Christophe Fillot. All rights reserved. |
* Copyright (c) 2006 Christophe Fillot. All rights reserved. |
4 |
|
* |
5 |
|
* RAM emulation. |
6 |
*/ |
*/ |
7 |
|
|
8 |
#include <stdio.h> |
#include <stdio.h> |
12 |
#include <errno.h> |
#include <errno.h> |
13 |
#include <unistd.h> |
#include <unistd.h> |
14 |
|
|
15 |
#include "mips64.h" |
#include "cpu.h" |
16 |
|
#include "vm.h" |
17 |
#include "dynamips.h" |
#include "dynamips.h" |
18 |
#include "memory.h" |
#include "memory.h" |
19 |
#include "device.h" |
#include "device.h" |
47 |
|
|
48 |
/* Initialize a RAM zone */ |
/* Initialize a RAM zone */ |
49 |
int dev_ram_init(vm_instance_t *vm,char *name,int use_mmap,int delete_file, |
int dev_ram_init(vm_instance_t *vm,char *name,int use_mmap,int delete_file, |
50 |
char *alternate_name,m_uint64_t paddr,m_uint32_t len) |
char *alternate_name,int sparse, |
51 |
|
m_uint64_t paddr,m_uint32_t len) |
52 |
{ |
{ |
53 |
struct ram_data *d; |
struct ram_data *d; |
54 |
|
|
78 |
} |
} |
79 |
} |
} |
80 |
|
|
81 |
if (!(d->dev = dev_create_ram(vm,name,d->filename,paddr,len))) { |
if (!(d->dev = dev_create_ram(vm,name,sparse,d->filename,paddr,len))) { |
82 |
fprintf(stderr,"RAM: unable to create device.\n"); |
fprintf(stderr,"RAM: unable to create device.\n"); |
83 |
goto err_dev_create; |
goto err_dev_create; |
84 |
} |
} |
94 |
} |
} |
95 |
|
|
96 |
/* Initialize a ghosted RAM zone */ |
/* Initialize a ghosted RAM zone */ |
97 |
int dev_ram_ghost_init(vm_instance_t *vm,char *name,char *filename, |
int dev_ram_ghost_init(vm_instance_t *vm,char *name,int sparse,char *filename, |
98 |
m_uint64_t paddr,m_uint32_t len) |
m_uint64_t paddr,m_uint32_t len) |
99 |
{ |
{ |
100 |
struct ram_data *d; |
struct ram_data *d; |
116 |
d->vm_obj.data = d; |
d->vm_obj.data = d; |
117 |
d->vm_obj.shutdown = (vm_shutdown_t)dev_ram_shutdown; |
d->vm_obj.shutdown = (vm_shutdown_t)dev_ram_shutdown; |
118 |
|
|
119 |
if (!(d->dev = dev_create_ghost_ram(vm,name,d->filename,paddr,len))) { |
if (!(d->dev = dev_create_ghost_ram(vm,name,sparse,d->filename, |
120 |
|
paddr,len))) |
121 |
|
{ |
122 |
fprintf(stderr,"RAM_ghost: unable to create device.\n"); |
fprintf(stderr,"RAM_ghost: unable to create device.\n"); |
123 |
goto err_dev_create; |
goto err_dev_create; |
124 |
} |
} |