byte * _f_handler_inst_db_op(byte * inst) {
	dword flags = 0;
	mem_full_ref dest;
	mem_full_ref src;
	dword rtype, arg1, arg2;
	byte * o = inst;
	dword target;
	/* these instructions have two operands */
	byte op = *(inst+1);
	switch(op) {
		case DB_INST_MOVZX:
			inst = modreg_analysis(inst+1, &dest, &src, &flags);
			flux_staple(RADDR(o),inst-o);
			return inst;
			break;
		case DB_INST_SETZ:			
			inst = modreg_analysis(inst+1, &dest, &src, &flags);
			flux_staple(RADDR(o),inst-o);
			return inst;
			break;
		case DB_INST_SETNZ:			
			inst = modreg_analysis(inst+1, &dest, &src, &flags);
			flux_staple(RADDR(o),inst-o);
			return inst;
		case DB_INST_JZ:
		case DB_INST_JGE:
			//flux_staple(RADDR(o),6);
			target = *(dword*)(inst+2);
			do_branch(RADDR(inst),(dword)RADDR(inst+6+target),6);
			return inst+6;
		case DB_INST_ADD:
			flux_staple(RADDR(o),6);
			return inst+6;
		case DB_INST_JNZ:
			flux_staple(RADDR(o),6);
			return inst+6;
		case DB_INST_IMUL:
			flux_staple(RADDR(o),4);
			return inst+4;

	}
	return inst;
}
byte * _f_handler_inst_jo(byte * inst) {
	char target = *(char*)(inst+1);
	
	do_branch(RADDR(inst),(dword)RADDR(inst+2+target),2);
	return inst+2;
}
Beispiel #3
0
int hboot_boot(int handle) {
	bootfunc_t boot_entry;
	uint32_t bootsize, listsize;
	void *bootlist;
	uint32_t l1_mem, *l1_table;
    
    printk("hboot_boot\n");
	l1_mem = get_high_pages(2);
	if (l1_mem == 0) {
		printk("Failed to allocate new l1 table\n");
		return -ENOMEM;
	}
    printk("got l1_mem\n");
	if (l1_mem & 0x3fff) {
		printk("unaligned l1 table\n");
		free_high_pages((void*)l1_mem, 2);
		return -EINVAL;
	} else {
		l1_table = (uint32_t*)l1_mem;
	}
    printk("about to build l1_table\n");
	build_l1_table(l1_table);

    printk("about to get bootentry\n");
	boot_entry = get_bootentry(&bootsize, handle);
	if (boot_entry == NULL) {
		return -EINVAL;
	}
    printk("about to get bootlist\n");
	bootlist = get_bootlist(&listsize, handle);
	if (bootlist == NULL) {
		return -ENOMEM;
	}
    printk("about to do_branch... bootlist[0x%4X : 0x%4X], listsize[%d], new_ttbl[0x%4x : 0x%4X], boot_entry[0x%4X : 0x%4x]\n", (int)bootlist, (int)virt_to_phys(bootlist), (int)listsize, (int)l1_table, (int)virt_to_phys(l1_table), (int)boot_entry, (int)virt_to_phys(boot_entry));

    disable_dss();

	preempt_disable();
	local_irq_disable();
	local_fiq_disable();

    if (emu_uart)
    {
        printk("About to activate emu uart\n");
        czecho_activate_emu_uart();
        reconfigure_uart();
    }
    else
    {
        printk("skipping emu uart activation\n");
    }
    printk("About to reconfigure uart\n");

	do_branch(bootlist, listsize, virt_to_phys(l1_table), boot_entry);

/*	not a chance	*/
#if 0
	set_ttbl_base(l1_old);
	local_fiq_enable();
	local_irq_enable();
	preempt_enable();
#else
	while (1);
#endif
	return -EBUSY;
}