Exemplo n.º 1
0
 def __init__(self,
              cpu_type=M68K_CPU_TYPE_68000,
              ram_size_kib=1024,
              use_labels=True,
              raise_on_main_run=True):
     # setup musashi components
     self.cpu_type = cpu_type
     self.cpu = emu.CPU(cpu_type)
     self.mem = emu.Memory(ram_size_kib)
     self.traps = emu.Traps()
     self.raise_on_main_run = raise_on_main_run
     # internal state
     if use_labels:
         self.label_mgr = LabelManager()
     else:
         self.label_mgr = None
     self.ram_total = ram_size_kib * 1024
     self.ram_bytes = self.ram_total - self.ram_begin
     self.error_reporter = ErrorReporter(self)
     self.run_states = []
     self.mem0 = 0
     self.mem4 = 0
     self.shutdown_func = None
     self.instr_hook = None
     self.cycles_per_run = 1000
     self.bail_out = False
     # call init
     self._alloc_trap()
     self._init_base_mem()
     self._setup_handler()
Exemplo n.º 2
0
 def __init__(self,
              cpu_type=M68K_CPU_TYPE_68000,
              ram_size_kib=1024,
              use_labels=True,
              raise_on_main_run=True,
              cycles_per_run=1000,
              max_cycles=0,
              cpu_name=None):
     if cpu_name is None:
         cpu_name = self._get_cpu_name(cpu_type)
     # setup musashi components
     self.cpu_type = cpu_type
     self.cpu_name = cpu_name
     self.cpu = emu.CPU(cpu_type)
     self.mem = emu.Memory(ram_size_kib)
     self.traps = emu.Traps()
     # internal state
     if use_labels:
         self.label_mgr = LabelManager()
     else:
         self.label_mgr = None
     self.raise_on_main_run = raise_on_main_run
     self.ram_total = ram_size_kib * 1024
     self.ram_bytes = self.ram_total - self.ram_begin
     self.error_reporter = ErrorReporter(self)
     self.run_states = []
     self.instr_hook = None
     self.cycles_per_run = cycles_per_run
     self.max_cycles = max_cycles
     self.bail_out = False
     # call init
     self._setup_handler()
     self._setup_quick_traps()
     self._init_cpu()
     self._init_base_mem()
Exemplo n.º 3
0
 def __init__(self, size_kib=16, fill=0, use_labels=True):
     self.cpu = MockCPU()
     self.mem = MockMemory(size_kib, fill)
     self.traps = MockTraps()
     if use_labels:
         self.label_mgr = LabelManager()
     else:
         self.label_mgr = None
Exemplo n.º 4
0
def libcore_create_lib_label_mgr_test():
    mem, traps, alloc, ctx = setup()
    impl = VamosTestLibrary()
    label_mgr = LabelManager()
    # create info for lib
    date = datetime.date(2012, 11, 12)
    info = LibInfo('vamostest.library', 42, 3, date)
    # create lib
    creator = LibCreator(alloc, traps, label_mgr)
    lib = creator.create_lib(info, ctx, impl)
    # free lib
    lib.free()
    assert alloc.is_all_free()
Exemplo n.º 5
0
def mem_alloc(request):
    from amitools.vamos.machine import Machine, MockMemory
    from amitools.vamos.mem import MemoryAlloc
    from amitools.vamos.label import LabelManager
    n = request.param
    if n == 'mach':
        m = Machine(use_labels=False)
        mem = m.get_mem()
        return mem, MemoryAlloc(mem)
    elif n == 'mach-label':
        m = Machine()
        mem = m.get_mem()
        return mem, MemoryAlloc(mem, label_mgr=m.get_label_mgr())
    elif n == 'mock':
        mem = MockMemory(fill=23)
        return mem, MemoryAlloc(mem)
    else:
        mem = MockMemory(fill=23)
        lm = LabelManager()
        return mem, MemoryAlloc(mem, label_mgr=lm)