Beispiel #1
0
/* start simulation, program loaded, processor precise state initialized */
void
sim_main(void)
{
  fprintf(stderr, "sim: ** starting *pipe* functional simulation **\n");

  /* must have natural byte/word ordering */
  if (sim_swap_bytes || sim_swap_words)
    fatal("sim: *pipe* functional simulation cannot swap bytes or words");

  /* set up initial default next PC */
  regs.regs_NPC = regs.regs_PC + sizeof(md_inst_t);
  /* maintain $r0 semantics */
  regs.regs_R[MD_REG_ZERO] = 0;
  fd.PC = regs.regs_PC - sizeof(md_inst_t);
 
  while (TRUE)
  {
	  //handle the pipeline in reverse so that the instruction could be handled in ascending order
	  sim_num_insn++;
	  do_stall();
	  do_wb();
	  do_mem();
	  do_ex();
	  do_id();
	  do_if();
	  dump_pipeline();
  }
}
Beispiel #2
0
/*===========================================================================*
 *				sys_task				     *
 *===========================================================================*/
PUBLIC void sys_task()
{
/* Main entry point of sys_task.  Get the message and dispatch on type. */

  register int r;

  while (TRUE) {
	receive(ANY, &m);

	switch (m.m_type) {	/* which system call */
	    case SYS_FORK:	r = do_fork(&m);	break;
	    case SYS_NEWMAP:	r = do_newmap(&m);	break;
	    case SYS_EXEC:	r = do_exec(&m);	break;
	    case SYS_XIT:	r = do_xit(&m);		break;
	    case SYS_GETSP:	r = do_getsp(&m);	break;
	    case SYS_TIMES:	r = do_times(&m);	break;
	    case SYS_ABORT:	r = do_abort(&m);	break;
#if (CHIP == M68000)
	    case SYS_FRESH:	r = do_fresh(&m);	break;
#endif
	    case SYS_SIG:	r = do_sig(&m);		break;
	    case SYS_KILL:	r = do_kill(&m);	break;
	    case SYS_COPY:	r = do_copy(&m);	break;
	    case SYS_GBOOT:	r = do_gboot(&m);	break;
	    case SYS_UMAP:	r = do_umap(&m);	break;
	    case SYS_MEM:	r = do_mem(&m);		break;
	    case SYS_TRACE:	r = do_trace(&m);	break;
	    default:		r = E_BAD_FCN;
	}

	m.m_type = r;		/* 'r' reports status of call */
	send(m.m_source, &m);	/* send reply to caller */
  }
}
Beispiel #3
0
/* start simulation, program loaded, processor precise state initialized */
void
sim_main(void)
{
  fprintf(stderr, "sim: ** starting *pipe* functional simulation **\n");

  /* must have natural byte/word ordering */
  if (sim_swap_bytes || sim_swap_words)
    fatal("sim: *pipe* functional simulation cannot swap bytes or words");

  /* set up initial default next PC */
  /* maintain $r0 semantics */
  regs.regs_R[MD_REG_ZERO] = 0;
  regs.regs_PC -= sizeof(md_inst_t);
  while (TRUE)
  {
	   do_if();
     do_wb();
     do_id();
     do_ex();
     do_mem();
     print_env();
     write_buf();
     #ifndef NO_INSN_COUNT
           sim_num_insn++;
     #endif /* !NO_INSN_COUNT */
  }
}
Beispiel #4
0
int main() {
  char* foo = strdup("hallo");
  printf("%s\n", foo);

  int* a = do_mem(10);
  a[0] = 1;
  free(a);

  FILE* f = fopen("test.c", "r");
  if(!f) {
    printf("WUT?\n");
  }
  char* line = NULL;
  size_t len;
  int ret = getline(&line, &len, f);
  printf("read ok: %d, line: %p\n", ret, line);
  printf("%s\n", line);
  free(line);

  char buffer[256];
  printf("fgets: %s\n", fgets(buffer, 256, f));
  printf("%s\n", buffer);

  if(!fread(buffer, 256, 1, f)) {
    *(int*)(0) = 1;
  }

  fclose(f);

  return 0;
}