-struct sim_state microblaze_state;
-
-int memcycles = 1;
-
-static SIM_OPEN_KIND sim_kind;
-static char *myname;
-
-static int issue_messages = 0;
-
-long
-int_sbrk (int inc_bytes)
-{
- long addr;
-
- addr = heap_ptr;
-
- heap_ptr += inc_bytes;
-
- if (issue_messages && heap_ptr > SP)
- fprintf (stderr, "Warning: heap_ptr overlaps stack!\n");
-
- return addr;
-}
-
-static void /* INLINE */
-wbat (word x, word v)
-{
- if (((uword)x) >= CPU.msize)
- {
- if (issue_messages)
- fprintf (stderr, "byte write to 0x%x outside memory range\n", x);
-
- CPU.exception = SIGSEGV;
- }
- else
- {
- unsigned char *p = CPU.memory + x;
- p[0] = v;
- }
-}
-
-static void /* INLINE */
-wlat (word x, word v)
-{
- if (((uword)x) >= CPU.msize)
- {
- if (issue_messages)
- fprintf (stderr, "word write to 0x%x outside memory range\n", x);
-
- CPU.exception = SIGSEGV;
- }
- else
- {
- if ((x & 3) != 0)
- {
- if (issue_messages)
- fprintf (stderr, "word write to unaligned memory address: 0x%x\n", x);
-
- CPU.exception = SIGBUS;
- }
- else if (!target_big_endian)
- {
- unsigned char *p = CPU.memory + x;
- p[3] = v >> 24;
- p[2] = v >> 16;
- p[1] = v >> 8;
- p[0] = v;
- }
- else
- {
- unsigned char *p = CPU.memory + x;
- p[0] = v >> 24;
- p[1] = v >> 16;
- p[2] = v >> 8;
- p[3] = v;
- }
- }
-}
-
-static void /* INLINE */
-what (word x, word v)
-{
- if (((uword)x) >= CPU.msize)
- {
- if (issue_messages)
- fprintf (stderr, "short write to 0x%x outside memory range\n", x);
-
- CPU.exception = SIGSEGV;
- }
- else
- {
- if ((x & 1) != 0)
- {
- if (issue_messages)
- fprintf (stderr, "short write to unaligned memory address: 0x%x\n",
- x);
-
- CPU.exception = SIGBUS;
- }
- else if (!target_big_endian)
- {
- unsigned char *p = CPU.memory + x;
- p[1] = v >> 8;
- p[0] = v;
- }
- else
- {
- unsigned char *p = CPU.memory + x;
- p[0] = v >> 8;
- p[1] = v;
- }
- }
-}
-
-/* Read functions. */
-static int /* INLINE */
-rbat (word x)
-{
- if (((uword)x) >= CPU.msize)
- {
- if (issue_messages)
- fprintf (stderr, "byte read from 0x%x outside memory range\n", x);
-
- CPU.exception = SIGSEGV;
- return 0;
- }
- else
- {
- unsigned char *p = CPU.memory + x;
- return p[0];
- }
-}
-
-static int /* INLINE */
-rlat (word x)
-{
- if (((uword) x) >= CPU.msize)
- {
- if (issue_messages)
- fprintf (stderr, "word read from 0x%x outside memory range\n", x);
-
- CPU.exception = SIGSEGV;
- return 0;
- }
- else
- {
- if ((x & 3) != 0)
- {
- if (issue_messages)
- fprintf (stderr, "word read from unaligned address: 0x%x\n", x);
-
- CPU.exception = SIGBUS;
- return 0;
- }
- else if (! target_big_endian)
- {
- unsigned char *p = CPU.memory + x;
- return (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
- }
- else
- {
- unsigned char *p = CPU.memory + x;
- return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
- }
- }
-}
-
-static int /* INLINE */
-rhat (word x)
-{
- if (((uword)x) >= CPU.msize)
- {
- if (issue_messages)
- fprintf (stderr, "short read from 0x%x outside memory range\n", x);
-
- CPU.exception = SIGSEGV;
- return 0;
- }
- else
- {
- if ((x & 1) != 0)
- {
- if (issue_messages)
- fprintf (stderr, "short read from unaligned address: 0x%x\n", x);
-
- CPU.exception = SIGBUS;
- return 0;
- }
- else if (!target_big_endian)
- {
- unsigned char *p = CPU.memory + x;
- return (p[1] << 8) | p[0];
- }
- else
- {
- unsigned char *p = CPU.memory + x;
- return (p[0] << 8) | p[1];
- }
- }
-}
-
-
-#define SEXTB(x) (((x & 0xff) ^ (~ 0x7f)) + 0x80)
-#define SEXTW(y) ((int)((short)y))
-
-static int
-IOMEM (int addr, int write, int value)
-{
-}
-
-/* Default to a 8 Mbyte (== 2^23) memory space. */
-static int sim_memory_size = 1 << 23;
-
-#define MEM_SIZE_FLOOR 64
-void
-sim_size (int size)
-{
- sim_memory_size = size;
- CPU.msize = sim_memory_size;
-
- if (CPU.memory)
- free (CPU.memory);
-
- CPU.memory = (unsigned char *) calloc (1, CPU.msize);
-
- if (!CPU.memory)
- {
- if (issue_messages)
- fprintf (stderr,
- "Not enough VM for simulation of %d bytes of RAM\n",
- CPU.msize);
-
- CPU.msize = 1;
- CPU.memory = (unsigned char *) calloc (1, 1);
- }
-}
-
-static void
-init_pointers ()
-{
- if (CPU.msize != (sim_memory_size))
- sim_size (sim_memory_size);
-}
-