* Makefile.in (sim-options_h): Define.

(sim-{module,options,trace,profile,utils}.o): Clean up dependencies.
	(sim-model.o): Add new rule.
	(cgen-{scache,trace,utils}.o): Add new rules.
	* aclocal.m4 (SIM_AC_OPTION_{SCACHE,DEFAULT_MODEL}): Add.
	* cgen-scache.c (scache_print_profile): Change `sd' arg to `cpu'.
	Indent output by 2 spaces.
	* cgen-scache.h (scache_print_profile): Update.
	* cgen-trace.c (trace_insn_fini): Indent output by 2 spaces.
	Use trace_printf, not fprintf.
	(trace_extract): Use trace_printf, not cgen_trace_printf.
	* genmloop.sh (!FAST case): Increment `insn_count'.
	* sim-base.h (sim_state_base): Only include scache_size if WITH_SCACHE.
	(sim_cpu_base): Rename member `sd' to `state' to be consistent with
	access macro's name.
	* sim-core.c (sim_core_init): Use EXTERN_SIM_CORE to define it.
	Change return type to SIM_RC.
	(sim_core_{install,uninstall}): New functions.
	* sim-core.h (sim_core_{install,uninstall}): Declare.
	(sim_core_init): Use EXTERN_SIM_CORE to define it.
	Change return type to SIM_RC.
	* sim-model.h (models,machs,model_install): Declare.
	* sim-module.c (modules): Add scache_install, model_install.
	(sim_post_argv_init): Set cpu->state backlinks.
	* sim-options.c (standard_options): Delete --simcache-size,--max-insns.
	(standard_option_handler): Likewise.
	* sim-profile.c (PROFILE_{HISTOGRAM,LABEL}_WIDTH): Move to
	sim-profile.h.
	(*): Assume ANSI C.
	(profile_options): Delete --profile-simcache.
	(profile_option_handler): Likewise.
	(profile_print_insn): Change `sd' arg to `cpu'.  Indent output 2
	spaces.
	(profile_print_{memory,model}): Likewise.
	(profile_print_simcache): Delete.
	(profile_print_speed): New function.
	(profile_print): Rewrite.
	* sim-profile.h (PROFILE_scache): Renamed from PROFILE_simcache.
	(WITH_PROFILE_SCACHE_P): Renamed from WITH_PROFILE_SIMCACHE_P.
	(PROFILE_DATA): Delete members simcache_{hits,misses}.
	(PROFILE_COUNT_SIMCACHE_{HIT,MISS}): Delete.
	(PROFILE_{CALLBACK,CPU_CALLBACK}): New types.
	(profile_print): Update prototype.
This commit is contained in:
David Edelsohn
1997-05-01 18:05:37 +00:00
parent 2c8f0de695
commit c967f1874a
11 changed files with 987 additions and 446 deletions

View File

@@ -22,38 +22,64 @@
#ifndef _SIM_CORE_C_
#define _SIM_CORE_C_
#include "engine.h"
#include "sim-main.h"
#include "sim-assert.h"
INLINE_SIM_CORE\
(void)
core_init(engine *system)
/* "core" module install handler.
This is called via sim_module_install to install the "core" subsystem
into the simulator. */
EXTERN_SIM_CORE\
(SIM_RC)
sim_core_install (SIM_DESC sd)
{
core *memory = &system->memory;
core_maps map;
sim_module_add_uninstall_fn (sd, sim_core_uninstall);
sim_module_add_init_fn (sd, sim_core_init);
return SIM_RC_OK;
}
/* Uninstall the "core" subsystem from the simulator. */
EXTERN_SIM_CORE\
(void)
sim_core_uninstall (SIM_DESC sd)
{
/* FIXME: free buffers, etc. */
}
EXTERN_SIM_CORE\
(SIM_RC)
sim_core_init (SIM_DESC sd)
{
sim_core *memory = &sd->core;
sim_core_maps map;
for (map = 0;
map < nr_core_maps;
map < nr_sim_core_maps;
map++) {
/* blow away old mappings */
core_mapping *curr = memory->map[map].first;
sim_core_mapping *curr = memory->map[map].first;
while (curr != NULL) {
core_mapping *tbd = curr;
sim_core_mapping *tbd = curr;
curr = curr->next;
if (tbd->free_buffer) {
ASSERT(tbd->buffer != NULL);
SIM_ASSERT(tbd->buffer != NULL);
zfree(tbd->buffer);
}
zfree(tbd);
}
memory->map[map].first = NULL;
}
return SIM_RC_OK;
}
STATIC_INLINE_SIM_CORE\
(core_mapping *)
new_core_mapping(engine *system,
(sim_core_mapping *)
new_sim_core_mapping(SIM_DESC sd,
attach_type attach,
int space,
unsigned_word addr,
@@ -62,7 +88,7 @@ new_core_mapping(engine *system,
void *buffer,
int free_buffer)
{
core_mapping *new_mapping = ZALLOC(core_mapping);
sim_core_mapping *new_mapping = ZALLOC(sim_core_mapping);
/* common */
new_mapping->level = attach;
new_mapping->space = space;
@@ -77,7 +103,7 @@ new_core_mapping(engine *system,
new_mapping->device = device;
}
else {
engine_error(system, "new_core_mapping - internal error - unknown attach type %d\n",
sim_io_error (sd, "new_sim_core_mapping - internal error - unknown attach type %d\n",
attach);
}
return new_mapping;
@@ -86,8 +112,8 @@ new_core_mapping(engine *system,
STATIC_INLINE_SIM_CORE\
(void)
core_map_attach(engine *system,
core_map *access_map,
sim_core_map_attach(SIM_DESC sd,
sim_core_map *access_map,
attach_type attach,
int space,
unsigned_word addr,
@@ -98,18 +124,18 @@ core_map_attach(engine *system,
{
/* find the insertion point for this additional mapping and then
insert */
core_mapping *next_mapping;
core_mapping **last_mapping;
sim_core_mapping *next_mapping;
sim_core_mapping **last_mapping;
ASSERT((attach >= attach_callback && client != NULL && buffer == NULL && !free_buffer)
SIM_ASSERT((attach >= attach_callback && client != NULL && buffer == NULL && !free_buffer)
|| (attach == attach_raw_memory && client == NULL && buffer != NULL));
/* actually do occasionally get a zero size map */
if (nr_bytes == 0) {
#if (WITH_DEVICES)
device_error(client, "called on core_map_attach with size zero");
device_error(client, "called on sim_core_map_attach with size zero");
#else
engine_error(system, "called on core_map_attach with size zero");
sim_io_error (sd, "called on sim_core_map_attach with size zero");
#endif
}
@@ -128,20 +154,20 @@ core_map_attach(engine *system,
}
/* check insertion point correct */
ASSERT(next_mapping == NULL || next_mapping->level >= attach);
SIM_ASSERT(next_mapping == NULL || next_mapping->level >= attach);
if (next_mapping != NULL && next_mapping->level == attach
&& next_mapping->base < (addr + (nr_bytes - 1))) {
#if (WITH_DEVICES)
device_error(client, "map overlap when attaching %d:0x%lx (%ld)",
space, (long)addr, (long)nr_bytes);
#else
engine_error(system, "map overlap when attaching %d:0x%lx (%ld)",
sim_io_error (sd, "map overlap when attaching %d:0x%lx (%ld)",
space, (long)addr, (long)nr_bytes);
#endif
}
/* create/insert the new mapping */
*last_mapping = new_core_mapping(system,
*last_mapping = new_sim_core_mapping(sd,
attach,
space, addr, nr_bytes,
client, buffer, free_buffer);
@@ -151,7 +177,7 @@ core_map_attach(engine *system,
INLINE_SIM_CORE\
(void)
core_attach(engine *system,
sim_core_attach(SIM_DESC sd,
attach_type attach,
access_type access,
int space,
@@ -160,8 +186,8 @@ core_attach(engine *system,
device *client,
void *optional_buffer)
{
core *memory = &system->memory;
core_maps map;
sim_core *memory = &sd->core;
sim_core_maps map;
void *buffer;
int buffer_freed;
if ((access & access_read_write_exec) == 0
@@ -169,7 +195,7 @@ core_attach(engine *system,
#if (WITH_DEVICES)
device_error(client, "invalid access for core attach");
#else
engine_error(system, "invalid access for core attach");
sim_io_error (sd, "invalid access for core attach");
#endif
}
/* verify the attach type */
@@ -189,44 +215,44 @@ core_attach(engine *system,
}
else {
#if (WITH_DEVICES)
device_error(client, "core_attach - conflicting buffer and attach arguments");
device_error(client, "sim_core_attach - conflicting buffer and attach arguments");
#else
engine_error(system, "core_attach - conflicting buffer and attach arguments");
sim_io_error (sd, "sim_core_attach - conflicting buffer and attach arguments");
#endif
buffer = NULL;
buffer_freed = 1;
}
/* attach the region to all applicable access maps */
for (map = 0;
map < nr_core_maps;
map < nr_sim_core_maps;
map++) {
switch (map) {
case core_read_map:
case sim_core_read_map:
if (access & access_read)
core_map_attach(system, &memory->map[map],
sim_core_map_attach(sd, &memory->map[map],
attach,
space, addr, nr_bytes,
client, buffer, !buffer_freed);
buffer_freed ++;
break;
case core_write_map:
case sim_core_write_map:
if (access & access_write)
core_map_attach(system, &memory->map[map],
sim_core_map_attach(sd, &memory->map[map],
attach,
space, addr, nr_bytes,
client, buffer, !buffer_freed);
buffer_freed ++;
break;
case core_execute_map:
case sim_core_execute_map:
if (access & access_exec)
core_map_attach(system, &memory->map[map],
sim_core_map_attach(sd, &memory->map[map],
attach,
space, addr, nr_bytes,
client, buffer, !buffer_freed);
buffer_freed ++;
break;
case nr_core_maps:
engine_error(system, "core_attach - internal error - bad switch");
case nr_sim_core_maps:
sim_io_error (sd, "sim_core_attach - internal error - bad switch");
break;
}
}
@@ -234,16 +260,16 @@ core_attach(engine *system,
STATIC_INLINE_SIM_CORE\
(core_mapping *)
core_map_find_mapping(engine *system,
core_maps map,
(sim_core_mapping *)
sim_core_find_mapping(SIM_DESC sd,
sim_core_maps map,
unsigned_word addr,
unsigned nr_bytes,
int abort) /*either 0 or 1 - helps inline */
{
core_mapping *mapping = system->memory.map[map].first;
ASSERT((addr & (nr_bytes - 1)) == 0); /* must be aligned */
ASSERT((addr + (nr_bytes - 1)) >= addr); /* must not wrap */
sim_core_mapping *mapping = sd->core.map[map].first;
SIM_ASSERT((addr & (nr_bytes - 1)) == 0); /* must be aligned */
SIM_ASSERT((addr + (nr_bytes - 1)) >= addr); /* must not wrap */
while (mapping != NULL) {
if (addr >= mapping->base
&& (addr + (nr_bytes - 1)) <= mapping->bound)
@@ -251,7 +277,7 @@ core_map_find_mapping(engine *system,
mapping = mapping->next;
}
if (abort)
engine_error(system, "access to unmaped address 0x%x (%d bytes)\n",
sim_io_error (sd, "access to unmaped address 0x%x (%d bytes)\n",
addr, nr_bytes);
return NULL;
}
@@ -259,7 +285,7 @@ core_map_find_mapping(engine *system,
STATIC_INLINE_SIM_CORE\
(void *)
core_translate(core_mapping *mapping,
sim_core_translate(sim_core_mapping *mapping,
unsigned_word addr)
{
return (void *)(((char *)mapping->buffer) + addr - mapping->base);
@@ -268,8 +294,8 @@ core_translate(core_mapping *mapping,
INLINE_SIM_CORE\
(unsigned)
core_map_read_buffer(engine *system,
core_maps map,
sim_core_read_buffer(SIM_DESC sd,
sim_core_maps map,
void *buffer,
unsigned_word addr,
unsigned len)
@@ -277,8 +303,8 @@ core_map_read_buffer(engine *system,
unsigned count = 0;
while (count < len) {
unsigned_word raddr = addr + count;
core_mapping *mapping =
core_map_find_mapping(system, map,
sim_core_mapping *mapping =
sim_core_find_mapping(sd, map,
raddr, 1,
0); /*dont-abort*/
if (mapping == NULL)
@@ -300,7 +326,7 @@ core_map_read_buffer(engine *system,
#endif
{
((unsigned_1*)buffer)[count] =
*(unsigned_1*)core_translate(mapping, raddr);
*(unsigned_1*)sim_core_translate(mapping, raddr);
count += 1;
}
}
@@ -310,8 +336,8 @@ core_map_read_buffer(engine *system,
INLINE_SIM_CORE\
(unsigned)
core_map_write_buffer(engine *system,
core_maps map,
sim_core_write_buffer(SIM_DESC sd,
sim_core_maps map,
const void *buffer,
unsigned_word addr,
unsigned len)
@@ -319,9 +345,9 @@ core_map_write_buffer(engine *system,
unsigned count = 0;
while (count < len) {
unsigned_word raddr = addr + count;
core_mapping *mapping = core_map_find_mapping(system, map,
raddr, 1,
0); /*dont-abort*/
sim_core_mapping *mapping = sim_core_find_mapping(sd, map,
raddr, 1,
0); /*dont-abort*/
if (mapping == NULL)
break;
#if (WITH_DEVICES)
@@ -341,7 +367,7 @@ core_map_write_buffer(engine *system,
else
#endif
{
*(unsigned_1*)core_translate(mapping, raddr) =
*(unsigned_1*)sim_core_translate(mapping, raddr) =
((unsigned_1*)buffer)[count];
count += 1;
}