* sim-core.h (SIM_CORE_SIGNAL_FN): New typedef.
* sim-core.c (sim_core_signal): Make extern, always define.
This commit is contained in:
parent
a28ad776ad
commit
169c74762a
3 changed files with 206 additions and 168 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Jun 11 00:50:03 1998 Doug Evans <devans@seba.cygnus.com>
|
||||||
|
|
||||||
|
* sim-core.h (SIM_CORE_SIGNAL_FN): New typedef.
|
||||||
|
* sim-core.c (sim_core_signal): Make extern, always define.
|
||||||
|
|
||||||
Wed Jun 10 16:02:29 1998 Doug Evans <devans@seba.cygnus.com>
|
Wed Jun 10 16:02:29 1998 Doug Evans <devans@seba.cygnus.com>
|
||||||
|
|
||||||
* Make-common.in (CGEN_FLAGS_TO_PASS): New variable.
|
* Make-common.in (CGEN_FLAGS_TO_PASS): New variable.
|
||||||
|
|
|
@ -19,12 +19,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SIM_CORE_C_
|
#ifndef SIM_CORE_C
|
||||||
#define _SIM_CORE_C_
|
#define SIM_CORE_C
|
||||||
|
|
||||||
#include "sim-main.h"
|
#include "sim-main.h"
|
||||||
#include "sim-assert.h"
|
#include "sim-assert.h"
|
||||||
|
|
||||||
|
#if (WITH_HW)
|
||||||
|
#include "sim-hw.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* "core" module install handler.
|
/* "core" module install handler.
|
||||||
|
|
||||||
This is called via sim_module_install to install the "core" subsystem
|
This is called via sim_module_install to install the "core" subsystem
|
||||||
|
@ -62,9 +66,9 @@ STATIC_SIM_CORE\
|
||||||
sim_core_uninstall (SIM_DESC sd)
|
sim_core_uninstall (SIM_DESC sd)
|
||||||
{
|
{
|
||||||
sim_core *core = STATE_CORE(sd);
|
sim_core *core = STATE_CORE(sd);
|
||||||
sim_core_maps map;
|
unsigned map;
|
||||||
/* blow away any mappings */
|
/* blow away any mappings */
|
||||||
for (map = 0; map < nr_sim_core_maps; map++) {
|
for (map = 0; map < nr_maps; map++) {
|
||||||
sim_core_mapping *curr = core->common.map[map].first;
|
sim_core_mapping *curr = core->common.map[map].first;
|
||||||
while (curr != NULL) {
|
while (curr != NULL) {
|
||||||
sim_core_mapping *tbd = curr;
|
sim_core_mapping *tbd = curr;
|
||||||
|
@ -93,13 +97,14 @@ sim_core_init (SIM_DESC sd)
|
||||||
#ifndef SIM_CORE_SIGNAL
|
#ifndef SIM_CORE_SIGNAL
|
||||||
#define SIM_CORE_SIGNAL(SD,CPU,CIA,MAP,NR_BYTES,ADDR,TRANSFER,ERROR) \
|
#define SIM_CORE_SIGNAL(SD,CPU,CIA,MAP,NR_BYTES,ADDR,TRANSFER,ERROR) \
|
||||||
sim_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), (TRANSFER), (ERROR))
|
sim_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), (TRANSFER), (ERROR))
|
||||||
|
#endif
|
||||||
|
|
||||||
STATIC_SIM_CORE\
|
EXTERN_SIM_CORE\
|
||||||
(void)
|
(void)
|
||||||
sim_core_signal (SIM_DESC sd,
|
sim_core_signal (SIM_DESC sd,
|
||||||
sim_cpu *cpu,
|
sim_cpu *cpu,
|
||||||
sim_cia cia,
|
sim_cia cia,
|
||||||
sim_core_maps map,
|
unsigned map,
|
||||||
int nr_bytes,
|
int nr_bytes,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
transfer_type transfer,
|
transfer_type transfer,
|
||||||
|
@ -124,21 +129,6 @@ sim_core_signal (SIM_DESC sd,
|
||||||
"sim_core_signal - internal error - bad switch");
|
"sim_core_signal - internal error - bad switch");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
EXTERN_SIM_CORE\
|
|
||||||
(const char *)
|
|
||||||
sim_core_map_to_str (sim_core_maps map)
|
|
||||||
{
|
|
||||||
switch (map)
|
|
||||||
{
|
|
||||||
case sim_core_read_map: return "read";
|
|
||||||
case sim_core_write_map: return "write";
|
|
||||||
case sim_core_execute_map: return "exec";
|
|
||||||
default: return "(invalid-map)";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
STATIC_SIM_CORE\
|
STATIC_SIM_CORE\
|
||||||
|
@ -149,7 +139,11 @@ new_sim_core_mapping (SIM_DESC sd,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
address_word nr_bytes,
|
address_word nr_bytes,
|
||||||
unsigned modulo,
|
unsigned modulo,
|
||||||
|
#if WITH_HW
|
||||||
|
struct hw *device,
|
||||||
|
#else
|
||||||
device *device,
|
device *device,
|
||||||
|
#endif
|
||||||
void *buffer,
|
void *buffer,
|
||||||
void *free_buffer)
|
void *free_buffer)
|
||||||
{
|
{
|
||||||
|
@ -180,7 +174,11 @@ sim_core_map_attach (SIM_DESC sd,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
address_word nr_bytes,
|
address_word nr_bytes,
|
||||||
unsigned modulo,
|
unsigned modulo,
|
||||||
|
#if WITH_HW
|
||||||
|
struct hw *client, /*callback/default*/
|
||||||
|
#else
|
||||||
device *client, /*callback/default*/
|
device *client, /*callback/default*/
|
||||||
|
#endif
|
||||||
void *buffer, /*raw_memory*/
|
void *buffer, /*raw_memory*/
|
||||||
void *free_buffer) /*raw_memory*/
|
void *free_buffer) /*raw_memory*/
|
||||||
{
|
{
|
||||||
|
@ -197,9 +195,11 @@ sim_core_map_attach (SIM_DESC sd,
|
||||||
{
|
{
|
||||||
#if (WITH_DEVICES)
|
#if (WITH_DEVICES)
|
||||||
device_error(client, "called on sim_core_map_attach with size zero");
|
device_error(client, "called on sim_core_map_attach with size zero");
|
||||||
#else
|
|
||||||
sim_io_error (sd, "called on sim_core_map_attach with size zero");
|
|
||||||
#endif
|
#endif
|
||||||
|
#if (WITH_HW)
|
||||||
|
sim_hw_abort (sd, client, "called on sim_core_map_attach with size zero");
|
||||||
|
#endif
|
||||||
|
sim_io_error (sd, "called on sim_core_map_attach with size zero");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find the insertion point (between last/next) */
|
/* find the insertion point (between last/next) */
|
||||||
|
@ -232,8 +232,9 @@ sim_core_map_attach (SIM_DESC sd,
|
||||||
(long) next_mapping->base,
|
(long) next_mapping->base,
|
||||||
(long) next_mapping->bound,
|
(long) next_mapping->bound,
|
||||||
(long) next_mapping->nr_bytes);
|
(long) next_mapping->nr_bytes);
|
||||||
#else
|
#endif
|
||||||
sim_io_error (sd, "memory map %d:0x%lx..0x%lx (%ld bytes) overlaps %d:0x%lx..0x%lx (%ld bytes)",
|
#if WITH_HW
|
||||||
|
sim_hw_abort (sd, client, "memory map %d:0x%lx..0x%lx (%ld bytes) overlaps %d:0x%lx..0x%lx (%ld bytes)",
|
||||||
space,
|
space,
|
||||||
(long) addr,
|
(long) addr,
|
||||||
(long) nr_bytes,
|
(long) nr_bytes,
|
||||||
|
@ -243,6 +244,15 @@ sim_core_map_attach (SIM_DESC sd,
|
||||||
(long) next_mapping->bound,
|
(long) next_mapping->bound,
|
||||||
(long) next_mapping->nr_bytes);
|
(long) next_mapping->nr_bytes);
|
||||||
#endif
|
#endif
|
||||||
|
sim_io_error (sd, "memory map %d:0x%lx..0x%lx (%ld bytes) overlaps %d:0x%lx..0x%lx (%ld bytes)",
|
||||||
|
space,
|
||||||
|
(long) addr,
|
||||||
|
(long) nr_bytes,
|
||||||
|
(long) (addr + (nr_bytes - 1)),
|
||||||
|
next_mapping->space,
|
||||||
|
(long) next_mapping->base,
|
||||||
|
(long) next_mapping->bound,
|
||||||
|
(long) next_mapping->nr_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create/insert the new mapping */
|
/* create/insert the new mapping */
|
||||||
|
@ -261,16 +271,20 @@ EXTERN_SIM_CORE\
|
||||||
sim_core_attach (SIM_DESC sd,
|
sim_core_attach (SIM_DESC sd,
|
||||||
sim_cpu *cpu,
|
sim_cpu *cpu,
|
||||||
int level,
|
int level,
|
||||||
access_type access,
|
unsigned mapmask,
|
||||||
int space,
|
int space,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
address_word nr_bytes,
|
address_word nr_bytes,
|
||||||
unsigned modulo,
|
unsigned modulo,
|
||||||
|
#if WITH_HW
|
||||||
|
struct hw *client,
|
||||||
|
#else
|
||||||
device *client,
|
device *client,
|
||||||
|
#endif
|
||||||
void *optional_buffer)
|
void *optional_buffer)
|
||||||
{
|
{
|
||||||
sim_core *memory = STATE_CORE(sd);
|
sim_core *memory = STATE_CORE(sd);
|
||||||
sim_core_maps map;
|
unsigned map;
|
||||||
void *buffer;
|
void *buffer;
|
||||||
void *free_buffer;
|
void *free_buffer;
|
||||||
|
|
||||||
|
@ -278,32 +292,26 @@ sim_core_attach (SIM_DESC sd,
|
||||||
if (cpu != NULL)
|
if (cpu != NULL)
|
||||||
sim_io_error (sd, "sim_core_map_attach - processor specific memory map not yet supported");
|
sim_io_error (sd, "sim_core_map_attach - processor specific memory map not yet supported");
|
||||||
|
|
||||||
if ((access & access_read_write_exec) == 0
|
|
||||||
|| (access & ~access_read_write_exec) != 0)
|
|
||||||
{
|
|
||||||
#if (WITH_DEVICES)
|
|
||||||
device_error(client, "invalid access for core attach");
|
|
||||||
#else
|
|
||||||
sim_io_error (sd, "invalid access for core attach");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* verify modulo memory */
|
/* verify modulo memory */
|
||||||
if (!WITH_MODULO_MEMORY && modulo != 0)
|
if (!WITH_MODULO_MEMORY && modulo != 0)
|
||||||
{
|
{
|
||||||
#if (WITH_DEVICES)
|
#if (WITH_DEVICES)
|
||||||
device_error (client, "sim_core_attach - internal error - modulo memory disabled");
|
device_error (client, "sim_core_attach - internal error - modulo memory disabled");
|
||||||
#else
|
|
||||||
sim_io_error (sd, "sim_core_attach - internal error - modulo memory disabled");
|
|
||||||
#endif
|
#endif
|
||||||
|
#if (WITH_HW)
|
||||||
|
sim_hw_abort (sd, client, "sim_core_attach - internal error - modulo memory disabled");
|
||||||
|
#endif
|
||||||
|
sim_io_error (sd, "sim_core_attach - internal error - modulo memory disabled");
|
||||||
}
|
}
|
||||||
if (client != NULL && modulo != 0)
|
if (client != NULL && modulo != 0)
|
||||||
{
|
{
|
||||||
#if (WITH_DEVICES)
|
#if (WITH_DEVICES)
|
||||||
device_error (client, "sim_core_attach - internal error - modulo and callback memory conflict");
|
device_error (client, "sim_core_attach - internal error - modulo and callback memory conflict");
|
||||||
#else
|
|
||||||
sim_io_error (sd, "sim_core_attach - internal error - modulo and callback memory conflict");
|
|
||||||
#endif
|
#endif
|
||||||
|
#if (WITH_HW)
|
||||||
|
sim_hw_abort (sd, client, "sim_core_attach - internal error - modulo and callback memory conflict");
|
||||||
|
#endif
|
||||||
|
sim_io_error (sd, "sim_core_attach - internal error - modulo and callback memory conflict");
|
||||||
}
|
}
|
||||||
if (modulo != 0)
|
if (modulo != 0)
|
||||||
{
|
{
|
||||||
|
@ -320,9 +328,11 @@ sim_core_attach (SIM_DESC sd,
|
||||||
{
|
{
|
||||||
#if (WITH_DEVICES)
|
#if (WITH_DEVICES)
|
||||||
device_error (client, "sim_core_attach - internal error - modulo %lx not power of two", (long) modulo);
|
device_error (client, "sim_core_attach - internal error - modulo %lx not power of two", (long) modulo);
|
||||||
#else
|
|
||||||
sim_io_error (sd, "sim_core_attach - internal error - modulo %lx not power of two", (long) modulo);
|
|
||||||
#endif
|
#endif
|
||||||
|
#if (WITH_HW)
|
||||||
|
sim_hw_abort (sd, client, "sim_core_attach - internal error - modulo %lx not power of two", (long) modulo);
|
||||||
|
#endif
|
||||||
|
sim_io_error (sd, "sim_core_attach - internal error - modulo %lx not power of two", (long) modulo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,9 +341,11 @@ sim_core_attach (SIM_DESC sd,
|
||||||
{
|
{
|
||||||
#if (WITH_DEVICES)
|
#if (WITH_DEVICES)
|
||||||
device_error (client, "sim_core_attach - internal error - conflicting buffer and attach arguments");
|
device_error (client, "sim_core_attach - internal error - conflicting buffer and attach arguments");
|
||||||
#else
|
|
||||||
sim_io_error (sd, "sim_core_attach - internal error - conflicting buffer and attach arguments");
|
|
||||||
#endif
|
#endif
|
||||||
|
#if (WITH_HW)
|
||||||
|
sim_hw_abort (sd, client, "sim_core_attach - internal error - conflicting buffer and attach arguments");
|
||||||
|
#endif
|
||||||
|
sim_io_error (sd, "sim_core_attach - internal error - conflicting buffer and attach arguments");
|
||||||
}
|
}
|
||||||
if (client == NULL)
|
if (client == NULL)
|
||||||
{
|
{
|
||||||
|
@ -359,35 +371,15 @@ sim_core_attach (SIM_DESC sd,
|
||||||
|
|
||||||
/* attach the region to all applicable access maps */
|
/* attach the region to all applicable access maps */
|
||||||
for (map = 0;
|
for (map = 0;
|
||||||
map < nr_sim_core_maps;
|
map < nr_maps;
|
||||||
map++)
|
map++)
|
||||||
{
|
{
|
||||||
switch (map)
|
if (mapmask & (1 << map))
|
||||||
{
|
{
|
||||||
case sim_core_read_map:
|
sim_core_map_attach (sd, &memory->common.map[map],
|
||||||
if (access & access_read)
|
level, space, addr, nr_bytes, modulo,
|
||||||
sim_core_map_attach (sd, &memory->common.map[map],
|
client, buffer, free_buffer);
|
||||||
level, space, addr, nr_bytes, modulo,
|
|
||||||
client, buffer, free_buffer);
|
|
||||||
free_buffer = NULL;
|
free_buffer = NULL;
|
||||||
break;
|
|
||||||
case sim_core_write_map:
|
|
||||||
if (access & access_write)
|
|
||||||
sim_core_map_attach (sd, &memory->common.map[map],
|
|
||||||
level, space, addr, nr_bytes, modulo,
|
|
||||||
client, buffer, free_buffer);
|
|
||||||
free_buffer = NULL;
|
|
||||||
break;
|
|
||||||
case sim_core_execute_map:
|
|
||||||
if (access & access_exec)
|
|
||||||
sim_core_map_attach (sd, &memory->common.map[map],
|
|
||||||
level, space, addr, nr_bytes, modulo,
|
|
||||||
client, buffer, free_buffer);
|
|
||||||
free_buffer = NULL;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sim_io_error (sd, "sim_core_attach - internal error - bad switch");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,8 +433,8 @@ sim_core_detach (SIM_DESC sd,
|
||||||
address_word addr)
|
address_word addr)
|
||||||
{
|
{
|
||||||
sim_core *memory = STATE_CORE (sd);
|
sim_core *memory = STATE_CORE (sd);
|
||||||
sim_core_maps map;
|
unsigned map;
|
||||||
for (map = 0; map < nr_sim_core_maps; map++)
|
for (map = 0; map < nr_maps; map++)
|
||||||
{
|
{
|
||||||
sim_core_map_detach (sd, &memory->common.map[map],
|
sim_core_map_detach (sd, &memory->common.map[map],
|
||||||
level, address_space, addr);
|
level, address_space, addr);
|
||||||
|
@ -463,7 +455,7 @@ sim_core_detach (SIM_DESC sd,
|
||||||
STATIC_INLINE_SIM_CORE\
|
STATIC_INLINE_SIM_CORE\
|
||||||
(sim_core_mapping *)
|
(sim_core_mapping *)
|
||||||
sim_core_find_mapping(sim_core_common *core,
|
sim_core_find_mapping(sim_core_common *core,
|
||||||
sim_core_maps map,
|
unsigned map,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
unsigned nr_bytes,
|
unsigned nr_bytes,
|
||||||
transfer_type transfer,
|
transfer_type transfer,
|
||||||
|
@ -509,45 +501,61 @@ EXTERN_SIM_CORE\
|
||||||
(unsigned)
|
(unsigned)
|
||||||
sim_core_read_buffer (SIM_DESC sd,
|
sim_core_read_buffer (SIM_DESC sd,
|
||||||
sim_cpu *cpu,
|
sim_cpu *cpu,
|
||||||
sim_core_maps map,
|
unsigned map,
|
||||||
void *buffer,
|
void *buffer,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
unsigned len)
|
unsigned len)
|
||||||
{
|
{
|
||||||
sim_core_common *core = (cpu == NULL ? &STATE_CORE (sd)->common : &CPU_CORE (cpu)->common);
|
sim_core_common *core = (cpu == NULL ? &STATE_CORE (sd)->common : &CPU_CORE (cpu)->common);
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
while (count < len) {
|
while (count < len)
|
||||||
|
{
|
||||||
unsigned_word raddr = addr + count;
|
unsigned_word raddr = addr + count;
|
||||||
sim_core_mapping *mapping =
|
sim_core_mapping *mapping =
|
||||||
sim_core_find_mapping(core, map,
|
sim_core_find_mapping (core, map,
|
||||||
raddr, /*nr-bytes*/1,
|
raddr, /*nr-bytes*/1,
|
||||||
read_transfer,
|
read_transfer,
|
||||||
0 /*dont-abort*/, NULL, NULL_CIA);
|
0 /*dont-abort*/, NULL, NULL_CIA);
|
||||||
if (mapping == NULL)
|
if (mapping == NULL)
|
||||||
break;
|
break;
|
||||||
#if (WITH_DEVICES)
|
#if (WITH_DEVICES)
|
||||||
if (mapping->device != NULL) {
|
if (mapping->device != NULL)
|
||||||
int nr_bytes = len - count;
|
|
||||||
if (raddr + nr_bytes - 1> mapping->bound)
|
|
||||||
nr_bytes = mapping->bound - raddr + 1;
|
|
||||||
if (device_io_read_buffer(mapping->device,
|
|
||||||
(unsigned_1*)buffer + count,
|
|
||||||
mapping->space,
|
|
||||||
raddr,
|
|
||||||
nr_bytes,
|
|
||||||
cpu,
|
|
||||||
CIA_GET(cpu)) != nr_bytes)
|
|
||||||
break;
|
|
||||||
count += nr_bytes;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
((unsigned_1*)buffer)[count] =
|
int nr_bytes = len - count;
|
||||||
*(unsigned_1*)sim_core_translate(mapping, raddr);
|
if (raddr + nr_bytes - 1> mapping->bound)
|
||||||
count += 1;
|
nr_bytes = mapping->bound - raddr + 1;
|
||||||
|
if (device_io_read_buffer (mapping->device,
|
||||||
|
(unsigned_1*)buffer + count,
|
||||||
|
mapping->space,
|
||||||
|
raddr,
|
||||||
|
nr_bytes,
|
||||||
|
cpu,
|
||||||
|
CIA_GET (cpu)) != nr_bytes)
|
||||||
|
break;
|
||||||
|
count += nr_bytes;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
#if (WITH_HW)
|
||||||
|
if (mapping->device != NULL)
|
||||||
|
{
|
||||||
|
int nr_bytes = len - count;
|
||||||
|
if (raddr + nr_bytes - 1> mapping->bound)
|
||||||
|
nr_bytes = mapping->bound - raddr + 1;
|
||||||
|
if (sim_hw_io_read_buffer (sd, mapping->device,
|
||||||
|
(unsigned_1*)buffer + count,
|
||||||
|
mapping->space,
|
||||||
|
raddr,
|
||||||
|
nr_bytes) != nr_bytes)
|
||||||
|
break;
|
||||||
|
count += nr_bytes;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
((unsigned_1*)buffer)[count] =
|
||||||
|
*(unsigned_1*)sim_core_translate(mapping, raddr);
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,46 +564,63 @@ EXTERN_SIM_CORE\
|
||||||
(unsigned)
|
(unsigned)
|
||||||
sim_core_write_buffer (SIM_DESC sd,
|
sim_core_write_buffer (SIM_DESC sd,
|
||||||
sim_cpu *cpu,
|
sim_cpu *cpu,
|
||||||
sim_core_maps map,
|
unsigned map,
|
||||||
const void *buffer,
|
const void *buffer,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
unsigned len)
|
unsigned len)
|
||||||
{
|
{
|
||||||
sim_core_common *core = (cpu == NULL ? &STATE_CORE (sd)->common : &CPU_CORE (cpu)->common);
|
sim_core_common *core = (cpu == NULL ? &STATE_CORE (sd)->common : &CPU_CORE (cpu)->common);
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
while (count < len) {
|
while (count < len)
|
||||||
unsigned_word raddr = addr + count;
|
{
|
||||||
sim_core_mapping *mapping =
|
unsigned_word raddr = addr + count;
|
||||||
sim_core_find_mapping(core, map,
|
sim_core_mapping *mapping =
|
||||||
raddr, /*nr-bytes*/1,
|
sim_core_find_mapping (core, map,
|
||||||
write_transfer,
|
raddr, /*nr-bytes*/1,
|
||||||
0 /*dont-abort*/, NULL, NULL_CIA);
|
write_transfer,
|
||||||
if (mapping == NULL)
|
0 /*dont-abort*/, NULL, NULL_CIA);
|
||||||
break;
|
if (mapping == NULL)
|
||||||
#if (WITH_DEVICES)
|
|
||||||
if (WITH_CALLBACK_MEMORY
|
|
||||||
&& mapping->device != NULL) {
|
|
||||||
int nr_bytes = len - count;
|
|
||||||
if (raddr + nr_bytes - 1 > mapping->bound)
|
|
||||||
nr_bytes = mapping->bound - raddr + 1;
|
|
||||||
if (device_io_write_buffer(mapping->device,
|
|
||||||
(unsigned_1*)buffer + count,
|
|
||||||
mapping->space,
|
|
||||||
raddr,
|
|
||||||
nr_bytes,
|
|
||||||
cpu,
|
|
||||||
CIA_GET(cpu)) != nr_bytes)
|
|
||||||
break;
|
break;
|
||||||
count += nr_bytes;
|
#if (WITH_DEVICES)
|
||||||
}
|
if (WITH_CALLBACK_MEMORY
|
||||||
else
|
&& mapping->device != NULL)
|
||||||
|
{
|
||||||
|
int nr_bytes = len - count;
|
||||||
|
if (raddr + nr_bytes - 1 > mapping->bound)
|
||||||
|
nr_bytes = mapping->bound - raddr + 1;
|
||||||
|
if (device_io_write_buffer (mapping->device,
|
||||||
|
(unsigned_1*)buffer + count,
|
||||||
|
mapping->space,
|
||||||
|
raddr,
|
||||||
|
nr_bytes,
|
||||||
|
cpu,
|
||||||
|
CIA_GET(cpu)) != nr_bytes)
|
||||||
|
break;
|
||||||
|
count += nr_bytes;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
{
|
#if (WITH_HW)
|
||||||
*(unsigned_1*)sim_core_translate(mapping, raddr) =
|
if (WITH_CALLBACK_MEMORY
|
||||||
((unsigned_1*)buffer)[count];
|
&& mapping->device != NULL)
|
||||||
count += 1;
|
{
|
||||||
}
|
int nr_bytes = len - count;
|
||||||
}
|
if (raddr + nr_bytes - 1 > mapping->bound)
|
||||||
|
nr_bytes = mapping->bound - raddr + 1;
|
||||||
|
if (sim_hw_io_write_buffer (sd, mapping->device,
|
||||||
|
(unsigned_1*)buffer + count,
|
||||||
|
mapping->space,
|
||||||
|
raddr,
|
||||||
|
nr_bytes) != nr_bytes)
|
||||||
|
break;
|
||||||
|
count += nr_bytes;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
*(unsigned_1*)sim_core_translate(mapping, raddr) =
|
||||||
|
((unsigned_1*)buffer)[count];
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,7 +662,7 @@ sim_core_set_xor (SIM_DESC sd,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (is_xor)
|
if (is_xor)
|
||||||
sim_engine_abort (sd, cpu, NULL_CIA,
|
sim_engine_abort (sd, NULL, NULL_CIA,
|
||||||
"Attempted to enable xor-endian mode when permenantly disabled.");
|
"Attempted to enable xor-endian mode when permenantly disabled.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -660,7 +685,7 @@ EXTERN_SIM_CORE\
|
||||||
(unsigned)
|
(unsigned)
|
||||||
sim_core_xor_read_buffer (SIM_DESC sd,
|
sim_core_xor_read_buffer (SIM_DESC sd,
|
||||||
sim_cpu *cpu,
|
sim_cpu *cpu,
|
||||||
sim_core_maps map,
|
unsigned map,
|
||||||
void *buffer,
|
void *buffer,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
unsigned nr_bytes)
|
unsigned nr_bytes)
|
||||||
|
@ -711,7 +736,7 @@ EXTERN_SIM_CORE\
|
||||||
(unsigned)
|
(unsigned)
|
||||||
sim_core_xor_write_buffer (SIM_DESC sd,
|
sim_core_xor_write_buffer (SIM_DESC sd,
|
||||||
sim_cpu *cpu,
|
sim_cpu *cpu,
|
||||||
sim_core_maps map,
|
unsigned map,
|
||||||
const void *buffer,
|
const void *buffer,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
unsigned nr_bytes)
|
unsigned nr_bytes)
|
||||||
|
|
|
@ -19,11 +19,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SIM_CORE_H_
|
#ifndef SIM_CORE_H
|
||||||
#define _SIM_CORE_H_
|
#define SIM_CORE_H
|
||||||
|
|
||||||
|
|
||||||
/* core signals (error conditions) */
|
/* core signals (error conditions)
|
||||||
|
Define SIM_CORE_SIGNAL to catch these signals - see sim-core.c for
|
||||||
|
details. */
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
sim_core_unmapped_signal,
|
sim_core_unmapped_signal,
|
||||||
|
@ -31,9 +33,12 @@ typedef enum {
|
||||||
nr_sim_core_signals,
|
nr_sim_core_signals,
|
||||||
} sim_core_signals;
|
} sim_core_signals;
|
||||||
|
|
||||||
/* define SIM_CORE_SIGNAL to catch these signals - see sim-core.c for
|
/* Type of SIM_CORE_SIGNAL handler. */
|
||||||
details */
|
typedef void (SIM_CORE_SIGNAL_FN)
|
||||||
|
(SIM_DESC sd, sim_cpu *cpu, sim_cia cia, unsigned map, int nr_bytes,
|
||||||
|
address_word addr, transfer_type transfer, sim_core_signals sig);
|
||||||
|
|
||||||
|
extern SIM_CORE_SIGNAL_FN sim_core_signal;
|
||||||
|
|
||||||
|
|
||||||
/* basic types */
|
/* basic types */
|
||||||
|
@ -51,7 +56,11 @@ struct _sim_core_mapping {
|
||||||
void *free_buffer;
|
void *free_buffer;
|
||||||
void *buffer;
|
void *buffer;
|
||||||
/* callback map */
|
/* callback map */
|
||||||
|
#if (WITH_HW)
|
||||||
|
struct hw *device;
|
||||||
|
#else
|
||||||
device *device;
|
device *device;
|
||||||
|
#endif
|
||||||
/* tracing */
|
/* tracing */
|
||||||
int trace;
|
int trace;
|
||||||
/* growth */
|
/* growth */
|
||||||
|
@ -63,16 +72,9 @@ struct _sim_core_map {
|
||||||
sim_core_mapping *first;
|
sim_core_mapping *first;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
sim_core_read_map,
|
|
||||||
sim_core_write_map,
|
|
||||||
sim_core_execute_map,
|
|
||||||
nr_sim_core_maps,
|
|
||||||
} sim_core_maps;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _sim_core_common {
|
typedef struct _sim_core_common {
|
||||||
sim_core_map map[nr_sim_core_maps];
|
sim_core_map map[nr_maps];
|
||||||
} sim_core_common;
|
} sim_core_common;
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,53 +103,58 @@ EXTERN_SIM_CORE\
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Create a memory space within the core.
|
/* Create a memory region within the core.
|
||||||
|
|
||||||
CPU, when non NULL, specifes the single processor that the memory
|
CPU - when non NULL, specifes the single processor that the memory
|
||||||
space is to be attached to. (UNIMPLEMENTED).
|
space is to be attached to. (INIMPLEMENTED).
|
||||||
|
|
||||||
LEVEL specifies the ordering of the memory region. Lower regions
|
LEVEL - specifies the ordering of the memory region. Lower regions
|
||||||
are searched first. Within a level, memory regions can not
|
are searched first. Within a level, memory regions can not
|
||||||
overlap.
|
overlap.
|
||||||
|
|
||||||
DEVICE, when non NULL, specifies a callback memory space.
|
MAPMASK - Bitmask specifying the memory maps that the region is to
|
||||||
(UNIMPLEMENTED, see the ppc simulator for an example).
|
be attached to. Typically the enums sim-basics.h:access_* are used.
|
||||||
|
|
||||||
MODULO, when the simulator has been configured WITH_MODULO support
|
ADDRESS_SPACE - For device regions, a MAP:ADDRESS pair is
|
||||||
|
translated into ADDRESS_SPACE:OFFSET before being passed to the
|
||||||
|
client device.
|
||||||
|
|
||||||
|
MODULO - when the simulator has been configured WITH_MODULO support
|
||||||
and is greater than zero, specifies that accesses to the region
|
and is greater than zero, specifies that accesses to the region
|
||||||
[ADDR .. ADDR+NR_BYTES) should be mapped onto the sub region [ADDR
|
[ADDR .. ADDR+NR_BYTES) should be mapped onto the sub region [ADDR
|
||||||
.. ADDR+MODULO). The modulo value must be a power of two.
|
.. ADDR+MODULO). The modulo value must be a power of two.
|
||||||
|
|
||||||
OPTIONAL_BUFFER, when non NULL, specifies the buffer to use for
|
DEVICE - When non NULL, indicates that this is a callback memory
|
||||||
|
space and specified device's memory callback handler should be
|
||||||
|
called.
|
||||||
|
|
||||||
|
OPTIONAL_BUFFER - when non NULL, specifies the buffer to use for
|
||||||
data read & written to the region. Normally a more efficient
|
data read & written to the region. Normally a more efficient
|
||||||
internal structure is used. It is assumed that buffer is allocated
|
internal structure is used. It is assumed that buffer is allocated
|
||||||
such that the byte alignmed of OPTIONAL_BUFFER matches ADDR vis
|
such that the byte alignmed of OPTIONAL_BUFFER matches ADDR vis
|
||||||
(OPTIONAL_BUFFER % 8) == (ADDR % 8)). It is defined to be a sub-optimal
|
(OPTIONAL_BUFFER % 8) == (ADDR % 8)). It is defined to be a sub-optimal
|
||||||
hook that allows clients to do nasty things that the interface doesn't
|
hook that allows clients to do nasty things that the interface doesn't
|
||||||
accomodate. ??? That seems unnecessarily restrictive. */
|
accomodate. */
|
||||||
|
|
||||||
EXTERN_SIM_CORE\
|
EXTERN_SIM_CORE\
|
||||||
(void) sim_core_attach
|
(void) sim_core_attach
|
||||||
(SIM_DESC sd,
|
(SIM_DESC sd,
|
||||||
sim_cpu *cpu,
|
sim_cpu *cpu,
|
||||||
int level,
|
int level,
|
||||||
access_type access,
|
unsigned mapmask,
|
||||||
int address_space,
|
int address_space,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
address_word nr_bytes,
|
address_word nr_bytes,
|
||||||
unsigned modulo,
|
unsigned modulo,
|
||||||
|
#if (WITH_HW)
|
||||||
|
struct hw *client,
|
||||||
|
#else
|
||||||
device *client,
|
device *client,
|
||||||
|
#endif
|
||||||
void *optional_buffer);
|
void *optional_buffer);
|
||||||
|
|
||||||
|
|
||||||
/* Utility to return the name of a map. */
|
/* Delete a memory section within the core.
|
||||||
|
|
||||||
EXTERN_SIM_CORE\
|
|
||||||
(const char *) sim_core_map_to_str
|
|
||||||
(sim_core_maps);
|
|
||||||
|
|
||||||
|
|
||||||
/* Delete a memory space within the core.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -177,7 +184,7 @@ EXTERN_SIM_CORE\
|
||||||
(unsigned) sim_core_read_buffer
|
(unsigned) sim_core_read_buffer
|
||||||
(SIM_DESC sd,
|
(SIM_DESC sd,
|
||||||
sim_cpu *cpu,
|
sim_cpu *cpu,
|
||||||
sim_core_maps map,
|
unsigned map,
|
||||||
void *buffer,
|
void *buffer,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
unsigned nr_bytes);
|
unsigned nr_bytes);
|
||||||
|
@ -186,7 +193,7 @@ EXTERN_SIM_CORE\
|
||||||
(unsigned) sim_core_write_buffer
|
(unsigned) sim_core_write_buffer
|
||||||
(SIM_DESC sd,
|
(SIM_DESC sd,
|
||||||
sim_cpu *cpu,
|
sim_cpu *cpu,
|
||||||
sim_core_maps map,
|
unsigned map,
|
||||||
const void *buffer,
|
const void *buffer,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
unsigned nr_bytes);
|
unsigned nr_bytes);
|
||||||
|
@ -226,7 +233,7 @@ EXTERN_SIM_CORE\
|
||||||
(unsigned) sim_core_xor_read_buffer
|
(unsigned) sim_core_xor_read_buffer
|
||||||
(SIM_DESC sd,
|
(SIM_DESC sd,
|
||||||
sim_cpu *cpu,
|
sim_cpu *cpu,
|
||||||
sim_core_maps map,
|
unsigned map,
|
||||||
void *buffer,
|
void *buffer,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
unsigned nr_bytes);
|
unsigned nr_bytes);
|
||||||
|
@ -235,7 +242,7 @@ EXTERN_SIM_CORE\
|
||||||
(unsigned) sim_core_xor_write_buffer
|
(unsigned) sim_core_xor_write_buffer
|
||||||
(SIM_DESC sd,
|
(SIM_DESC sd,
|
||||||
sim_cpu *cpu,
|
sim_cpu *cpu,
|
||||||
sim_core_maps map,
|
unsigned map,
|
||||||
const void *buffer,
|
const void *buffer,
|
||||||
address_word addr,
|
address_word addr,
|
||||||
unsigned nr_bytes);
|
unsigned nr_bytes);
|
||||||
|
@ -268,7 +275,7 @@ INLINE_SIM_CORE\
|
||||||
(void) sim_core_write_##ALIGNMENT##_##N \
|
(void) sim_core_write_##ALIGNMENT##_##N \
|
||||||
(sim_cpu *cpu, \
|
(sim_cpu *cpu, \
|
||||||
sim_cia cia, \
|
sim_cia cia, \
|
||||||
sim_core_maps map, \
|
unsigned map, \
|
||||||
address_word addr, \
|
address_word addr, \
|
||||||
unsigned_##M val);
|
unsigned_##M val);
|
||||||
|
|
||||||
|
@ -307,7 +314,7 @@ INLINE_SIM_CORE\
|
||||||
(unsigned_##M) sim_core_read_##ALIGNMENT##_##N \
|
(unsigned_##M) sim_core_read_##ALIGNMENT##_##N \
|
||||||
(sim_cpu *cpu, \
|
(sim_cpu *cpu, \
|
||||||
sim_cia cia, \
|
sim_cia cia, \
|
||||||
sim_core_maps map, \
|
unsigned map, \
|
||||||
address_word addr);
|
address_word addr);
|
||||||
|
|
||||||
DECLARE_SIM_CORE_READ_N(aligned,1,1)
|
DECLARE_SIM_CORE_READ_N(aligned,1,1)
|
||||||
|
@ -340,4 +347,5 @@ DECLARE_SIM_CORE_READ_N(misaligned,7,8)
|
||||||
|
|
||||||
#undef DECLARE_SIM_CORE_READ_N
|
#undef DECLARE_SIM_CORE_READ_N
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue