Ejemplo n.º 1
0
    def init_state(self, exe_file, exe_name, run_argv, run_envp, testbin):

        # Load the program into a memory object

        mem = Memory(size=memory_size, byte_storage=False)
        entrypoint, breakpoint = load_program(
            #open( filename, 'rb' ),
            exe_file,
            mem,
            # TODO: GEM5 uses this alignment, remove?
            alignment=1 << 12)

        self.state = syscall_init(mem, entrypoint, breakpoint, run_argv,
                                  run_envp, self.debug)
Ejemplo n.º 2
0
  def init_state( self, exe_file, exe_name, run_argv, run_envp, testbin ):

    # Load the program into a memory object

    mem = Memory( size=memory_size, byte_storage=False )
    entrypoint, breakpoint = load_program(
        #open( filename, 'rb' ),
        exe_file,
        mem,
        # TODO: GEM5 uses this alignment, remove?
        alignment = 1<<12
    )

    self.state = syscall_init( mem, entrypoint, breakpoint,
                               run_argv, run_envp, self.debug )
Ejemplo n.º 3
0
    def init_state(self, exe_file, exe_name, run_argv, run_envp, testbin):

        # Load the program into a memory object

        mem = Memory(size=memory_size, byte_storage=False)
        entrypoint, breakpoint = load_program(exe_file, mem)

        # Insert bootstrapping code into memory and initialize processor state

        if testbin: self.state = test_init(mem, self.debug)
        else:
            self.state = syscall_init(mem, breakpoint, run_argv, run_envp,
                                      self.debug)

        self.state.testbin = testbin
        self.state.exe_name = exe_name
Ejemplo n.º 4
0
  def init_state( self, exe_file, exe_name, run_argv, run_envp, testbin ):

    # Load the program into a memory object

    mem = Memory( size=memory_size, byte_storage=False )

    # TODO: assume 64-bit for now

    entrypoint, breakpoint = load_program( exe_file, mem, is_64bit=True )

    # Insert bootstrapping code into memory and initialize processor state

    #if testbin: self.state = test_init   ( mem, self.debug )
    #else:       self.state = syscall_init( mem, breakpoint, run_argv,
    #                                       run_envp, self.debug )
    if testbin:
      self.state = test_init( mem, self.debug )
    else:
      self.state = syscall_init( mem, breakpoint, run_argv,
                                           run_envp, self.debug )

    self.state.testbin  = testbin
    self.state.exe_name = exe_name
Ejemplo n.º 5
0
def entry_point(argv):

    filename_idx = 0
    debug_flags = []
    testbin = False
    max_insts = 0

    # we're using a mini state machine to parse the args, and these are two
    # states we have

    ARGS = 0
    DEBUG_FLAGS = 1
    MAX_INSTS = 2
    token_type = ARGS

    # go through the args one by one and parse accordingly

    for i in xrange(1, len(argv)):
        token = argv[i]

        if token_type == ARGS:

            if token == "--help":
                print help_message % argv[0]
                return 0

            elif token == "--test":
                testbin = True

            elif token == "--debug":
                token_type = DEBUG_FLAGS
                # warn the user if debugs are not enabled for this translation
                if not Debug.global_enabled:
                    print "WARNING: debugs are not enabled for this translation. " + \
                          "To allow debugs, translate with --debug option."

            elif token == "--max-insts":
                token_type = MAX_INSTS

            elif token[:2] == "--":
                # unknown option
                print "Unknown argument %s" % token
                return 1

            else:
                # this marks the start of the program name
                filename_idx = i
                break

        elif token_type == DEBUG_FLAGS:
            debug_flags = token.split(",")
            token_type = ARGS
        elif token_type == MAX_INSTS:
            max_insts = int(token)
            token_type = ARGS

    if filename_idx == 0:
        print "You must supply a filename"
        return 1

    filename = argv[filename_idx]

    # args after program are args to the simulated program

    run_argv = argv[filename_idx:]

    # Load the program into a memory object

    mem = Memory(size=memory_size, byte_storage=False)
    entrypoint, breakpoint = load_program(
        open(filename, 'rb'),
        mem,
        # TODO: GEM5 uses this alignment, remove?
        alignment=1 << 12)

    # create a Debug object which contains the debug flags

    debug = Debug()
    debug.set_flags(debug_flags)

    # Insert bootstrapping code into memory and initialize processor state

    state = syscall_init(mem, entrypoint, breakpoint, run_argv, debug)

    # Execute the program

    run(state, max_insts)

    return 0