Example #1
0
int main(int argc, char** argv)
{
	unsigned long data;
	struct termios term;
	char data2;
	int hasdat;
	int fd;
	
	if (argc != 1)
	{
usage:
		fprintf(stderr,
			"%s: a program to watch for stuff coming out over the console over jtag.\n", argv[0]);
		exit(1);
	}
	
	openport();
	
	test_reset();		// returns us in reset state
	clockin(0, 0);		// this leaves us in run-test/idle
	look_for_pxa();		// returns us in run-test/idle state
	
	set_instr(DBGTX);	
	/* We do not do any of the high-level stuff here. Just wait for RR and read. */
	while(1)
	{
		int lcount = 0;
		hasdat = 0;
		while (!hasdat)
		{
			hasdat = gettxword(&data);
			if (!hasdat)
				lcount++;
			if (lcount > 10)
				set_instr(DBGTX);
		}
 		data2 = data & 0xFF;
 		write(1, &data2, 1);
	}
	
	closeport();
	return 0;
}
Example #2
0
uint32_t set_instr_reg(uint32_t input_instr, sisa_opnd_t reg_opnd, uint32_t new_val)
{
    return set_instr(input_instr, reg_opnd.start_bit, reg_opnd.end_bit, new_val);
}
Example #3
0
void jellyfish::run()
{
    // get pc
    s32 pc=peekix(REG_PCO)%m_heap_size;
    
    // fetch instruction
    vec3 c=peek(pc);
    s32 i=(int)c.x;
    s32 argiy=(int)c.y;
    s32 argiz=(int)c.z;

    set_instr(pc,true);

    //printf("%d",i);
    
	switch(i)
	{
    case NOP: break;
    case JMP: poke(REG_PCO,vec3(argiy-1,0,0)); break;
    case JMZ: if ((float)pop().x==0) poke(REG_PCO,vec3(pc+argiy,0,0)); break;
	case JLT: if (pop().x<pop().x) poke(REG_PCO,vec3(pc+argiy,0,0)); break;
    case JGT: if (pop().x>pop().x) poke(REG_PCO,vec3(pc+argiy,0,0)); break;
	case LDL: push(vec3(c.y,0,0)); break;
	case LDA: push(peek(argiy)+argiz); break;
	case LDI: push(peek(peekix(argiy)+argiz)); break;
	case STA: poke(argiy+argiz,pop()); break;
	case STI: poke(peekix(argiy)+argiz,pop()); break;
	case ADD: push(pop()+pop()); break;
	case SUB: push(pop()-pop()); break;
	case MUL: 
    {
        vec3 m=pop();
        vec3 v=pop();
        push(v*(float)m.x);
    } break;
	case DIV: { 
        float v=(float)pop().x;
        if (v!=0) {
            push(pop()/v); 
        } else {
            push(vec3(0,0,0));
        }
    } break;
	case ABS: { vec3 t=pop(); push(vec3(fabs((float)t.x),
                                        fabs((float)t.y),
                                        fabs((float)t.z))); } break;
	case SIN: { flx_real a=pop().x; push(vec3(sin(((float)a)*0.0174532925),
                                              cos(((float)a)*0.0174532925),0));
    } break;
	case ATN: ; break;
	case DOT: push(vec3(pop().dot(pop()),0,0)); break;
	case CRS: push(pop().cross(pop())); break;
	case SQR: push(vec3(sqrt((float)pop().x),0,0)); break;
	case LEN: push(vec3(pop().mag(),0,0)); break;
	case DUP: push(top()); break;
	case CMP: push(vec3(pop().x,pop().x,pop().x)); break;
	case SHF: 
    { 
        vec3 shf=pop(); 
        vec3 src=pop();
        vec3 dst;        
        dst.x=(&src.x)[((int)fabs(shf.x))%3];
        if ((float)shf.x<0) dst.x=-dst.x;
        dst.y=(&src.x)[((int)fabs(shf.y))%3];
        if ((float)shf.y<0) dst.y=-dst.y;
        dst.z=(&src.x)[((int)fabs(shf.z))%3];
        if ((float)shf.z<0) dst.z=-dst.z;
        push(dst);
    } break;
	case BLD: 
    {
        vec3 ret;
        for (int i=0; i<3; i++)
        {
            vec3 t=peek(argiy);
            ret.x=(&t.x)[argiz];
        }
        push(ret);
    } break;
	case RET: poke(REG_PCO,vec3((int)pop().x,0,0)); break;
    default: set_instr(pc,false);
   	};



//    print_instr(pc);
//    printf("\n");
    
    // inc pc 
    // todo - speed?
    poke(REG_PCO,peek(REG_PCO)+vec3(1,0,0));
}
Example #4
0
/* XXX Note, this fuction does not currently handle faults from
 * vmalloc/vmaped'd memory. That should probably be in a separate
 * function anyway.
 */
int
l4_do_page_fault(unsigned long address, long access, struct pt_regs *regs)
{
	struct vm_area_struct * vma;
	struct mm_struct *mm = current->mm;
	int fault, si_code = SEGV_MAPERR;
	siginfo_t info;

	/* If we're in an interrupt context, or have no user context,
	   we must not take the fault.  */
	if (!mm) /* || in_interrupt()) */
		goto bad_area_nosemaphore;

	down_read(&mm->mmap_sem);
	vma = find_vma(mm, address);
	if (!vma)
		goto bad_area;
	if (vma->vm_start <= address)
		goto good_area;
	if (!(vma->vm_flags & VM_GROWSDOWN))
		goto bad_area;
	if (expand_stack(vma, address))
		goto bad_area;

	/* Ok, we have a good vm_area for this memory access, so
	   we can handle it.  */
 good_area:
	si_code = SEGV_ACCERR;
	if (/* LOAD */ access & 0x4) {
		/* Allow reads even for write/execute-only mappings */
		if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
			goto bad_area;
	} else if (/* FETCH */ access & 0x1) {
		if (!(vma->vm_flags & VM_EXEC))
			goto bad_area;
	} else {
		if (!(vma->vm_flags & VM_WRITE))
			goto bad_area;
	}

 survive:
	/* If for any reason at all we couldn't handle the fault,
	   make sure we exit gracefully rather than endlessly redo
	   the fault.  */

	fault = handle_mm_fault(mm, vma, address, access & 0x2);
	up_read(&mm->mmap_sem);

	switch (fault) {
		case VM_FAULT_MINOR:
			current->min_flt++;
			break;
 		case VM_FAULT_MAJOR:
			current->maj_flt++;
			break;
		case VM_FAULT_SIGBUS:
			goto do_sigbus;
		case VM_FAULT_OOM:
			goto out_of_memory;
#if 0
	/*
	 * Well, it's a good idea to have this here, but apparently
	 * handle_mm_fault() can return all sorts of weird stuff, which
	 * makes it unsuitable to put BUG() here. 	-gl
	 */
	      default:
		BUG();
#endif
	}
	return 0;

	/* Something tried to access memory that isn't in our memory map.
	   Fix it, but check if it's kernel or user first.  */
bad_area:
	up_read(&mm->mmap_sem);
	/* Check if it is at TASK_SIG_BASE */
#ifdef CONFIG_ARCH_ARM
	/*
	 * Binary patching for NPTL
	 *
	 * XXX ??? Better place this thing?
	 */
	if (user_mode(regs) && ((address & PAGE_MASK) == 0xffff0000)) {
#if 0
		printk("Fault at address 0x%lx pc = 0x%lx, "
		    "need rewrite\n", address, L4_MsgWord(&current_regs()->msg, 1));
#endif
		if (address == 0xffff0fe0) {
			L4_Msg_t msg;
			unsigned long pc = L4_MsgWord(&current_regs()->msg, 1);
			unsigned long lr, fpc;
			unsigned long instr, r;
			long offs;

			if (pc != 0xffff0fe0)
				goto bad_area_nosemaphore;

			L4_Copy_regs_to_mrs(task_thread_info(current)->user_tid);
			L4_StoreMRs(0, 16, &msg.msg[0]);
			lr = msg.msg[14];
			fpc = lr - 4;

			L4_CacheFlushAll();
			instr = get_instr(fpc);
			if (instr == -1UL) 
				goto bad_area_nosemaphore;

			if ((instr & 0x0f000000) == 0x0b000000) {
				offs = instr << 8;
				offs = offs >> 6;	/* ASR */

				fpc = (fpc + 8) + offs;
				instr = get_instr(fpc);
				if (instr == -1UL)
					goto bad_area_nosemaphore;

				if ((instr & 0xffffffff) == 0xe3e00a0f) {
					/* mvn r0, 0xf000 */

					/*
					 * Rewrite to load the 
					 * kernel_reserved[0] from the
				 	 * utcb.
					 *
					 * This requires L4 to cooperate
					 * with the ExReg() syscall.
					 */
					/* mov r0, #0xff000000 */
					r = set_instr(fpc, 0xe3a004ff);
					if (r == -1UL)
						goto bad_area_nosemaphore;
					fpc += 4;

					/* ldr r0, [r0, #0xff0] */
					r = set_instr(fpc, 0xe5900ff0);
					if (r == -1UL)
						goto bad_area_nosemaphore;
					fpc += 4;

					/* ldr r0, [r0, #56] */
					r = set_instr(fpc, 0xe5900038);
					if (r == -1UL)
						goto bad_area_nosemaphore;
					fpc += 4;

					/* mov pc, lr */
					r = set_instr(fpc, 0xe1a0f00e);
					if (r == -1UL) 
						goto bad_area_nosemaphore;
					L4_CacheFlushAll();

					msg.msg[0] = current_thread_info()->tp_value;
					msg.msg[15] = lr;
					L4_LoadMRs(0, 16, &msg.msg[0]);
					L4_Copy_mrs_to_regs(
					    task_thread_info(current)->user_tid);
					L4_MsgPutWord(&current_regs()->msg, 1,
					    lr);
					return 0;
				}
			} else if (instr == 0xe240f01f) {