Exemplo n.º 1
0
Arquivo: main.c Projeto: dev-zzo/mette
int main(int argc, char *argv[])
{
	int fd;
	vm_module_t *module;
	vm_context_t *context;

	argv++; argc--;

	if (argc == 0) {
		rtl_print_fd(2, "main: no file name provided.\n");
		return 1;
	}

	rtl_print_fd(2, "main: reading '%s'\n", argv[0]);
	
	fd = vm_open(argv[0], O_RDONLY, 0);
	if (fd < 0) {
		vm_panic("vm_load_exec: failed to open the image.");
	}
	
	module = vm_load_fd(fd);
	vm_close(fd);
	if (!module) {
		vm_panic("vm_load_exec: failed to load the image.");
	}

	context = vm_context_create(module);
	
	for (;;) {
		vm_step(context);
	}
	
	rtl_print_fd(1, "\n\nDone.\n");
	return 0;
}
Exemplo n.º 2
0
int
main(int argc, char **argv)
{
    char *endptr;
    unsigned long nsteps = 1000000;
    VMState *state;
    bool hit_bp = false;
#ifdef WITH_DIFF
    VMStateDiff *diff;
#endif
    
    if (argc <= 1) {
        printf("Using a default of %lu steps\n", nsteps);
    } else {
        nsteps = strtoul(argv[1], &endptr, 0);
        
        if (errno) {
            perror("Invalid command line argument.");
            return 1;
        }
        
        if (*endptr)
            fprintf(stderr, "Warning: junk at end of number.\n");
    }
    

    check_error(state = vm_newstate_no_code(VM_POLICY_INTERRUPT_ALWAYS));
    
    put_code(state);
    
#ifdef WITH_DIFF
    check_error(diff = vm_newdiff());
    if (!vm_step(state, nsteps, diff, &hit_bp))
        goto error;
#else
    if (!vm_step(state, nsteps, NULL, &hit_bp))
        goto error;
#endif
    
    return EXIT_SUCCESS;
error:
    fputs(vm_strerror(-1), stderr);
    fputc('\n', stderr);
    return EXIT_FAILURE;
}
Exemplo n.º 3
0
Arquivo: vm.c Projeto: sihida/essig
bool
vm_cont(VMState *state, VMStateDiff *diff, bool *hit_bp)
{
    while (true) {
        if (!vm_step(state, 1000, diff, hit_bp))
            return false;
        if (*hit_bp)
            break;
    }
    return true;
}
Exemplo n.º 4
0
Arquivo: vm.c Projeto: kisom/kam
/*
 * vm_run continues to step through the VM until an ERR or STOP condition
 * is signalled.
 */
int
vm_run(machine vm, uint8_t *prog, uint16_t prog_len)
{
	int	vm_status;

	do {
		vm_status = vm_step(vm, prog, prog_len);

	} while (VM_OK == vm_status);

	return vm_status;
}
Exemplo n.º 5
0
Arquivo: vm.c Projeto: terrayi/vm
int vm_run(VM *vm)
{
	int ret = 0;

	if (vm->State != VM_LOADED)
	{
		return VM_RET_ERROR;
	}

	vm->State = VM_RUNNING;

	while (vm->State == VM_RUNNING)
	{
		ret = vm_step(vm);

		if (ret != VM_RET_OK)
		{
			return ret;
		}
	}

	return VM_RET_OK;
}
Exemplo n.º 6
0
Arquivo: cpu.c Projeto: uecker/toys
void vm(reg_t regs[256], mem_t* mem)
{
	while(vm_step(regs, mem))
		;
}