예제 #1
0
/* Handle a floating point exception.  Return zero if the faulting
   instruction can be completed successfully. */
int
handle_fpe(struct pt_regs *regs)
{
	extern void printbinary(unsigned long x, int nbits);
	struct siginfo si;
	unsigned int orig_sw, sw;
	int signalcode;
	/* need an intermediate copy of float regs because FPU emulation
	 * code expects an artificial last entry which contains zero
	 *
	 * also, the passed in fr registers contain one word that defines
	 * the fpu type. the fpu type information is constructed 
	 * inside the emulation code
	 */
	__u64 frcopy[36];

	memcpy(frcopy, regs->fr, sizeof regs->fr);
	frcopy[32] = 0;

	memcpy(&orig_sw, frcopy, sizeof(orig_sw));

	if (FPUDEBUG) {
		printk(KERN_DEBUG "FP VZOUICxxxxCQCQCQCQCQCRMxxTDVZOUI ->\n   ");
		printbinary(orig_sw, 32);
		printk(KERN_DEBUG "\n");
	}

	signalcode = decode_fpu(frcopy, 0x666);

	/* Status word = FR0L. */
	memcpy(&sw, frcopy, sizeof(sw));
	if (FPUDEBUG) {
		printk(KERN_DEBUG "VZOUICxxxxCQCQCQCQCQCRMxxTDVZOUI decode_fpu returns %d|0x%x\n",
			signalcode >> 24, signalcode & 0xffffff);
		printbinary(sw, 32);
		printk(KERN_DEBUG "\n");
	}

	memcpy(regs->fr, frcopy, sizeof regs->fr);
	if (signalcode != 0) {
	    si.si_signo = signalcode >> 24;
	    si.si_errno = 0;
	    si.si_code = signalcode & 0xffffff;
	    si.si_addr = (void *) regs->iaoq[0];
	    force_sig_info(si.si_signo, &si, current);
	    return -1;
	}
예제 #2
0
void show_regs(struct pt_regs *regs)
{
	int i;
	char buf[128], *p;
	char *level;
	unsigned long cr30;
	unsigned long cr31;

	level = user_mode(regs) ? KERN_DEBUG : KERN_CRIT;

	printk("%s\n", level); /* don't want to have that pretty register dump messed up */

	printk("%s     YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI\n", level);
	printbinary(buf, regs->gr[0], 32);
	printk("%sPSW: %s %s\n", level, buf, print_tainted());

	for (i = 0; i < 32; i += 4) {
		int j;
		p = buf;
		p += sprintf(p, "%sr%02d-%02d ", level, i, i + 3);
		for (j = 0; j < 4; j++) {
			p += sprintf(p, " " RFMT, (i+j) == 0 ? 0 : regs->gr[i + j]);
		}
		printk("%s\n", buf);
	}

	for (i = 0; i < 8; i += 4) {
		int j;
		p = buf;
		p += sprintf(p, "%ssr%d-%d  ", level, i, i + 3);
		for (j = 0; j < 4; j++) {
			p += sprintf(p, " " RFMT, regs->sr[i + j]);
		}
		printk("%s\n", buf);
	}

#if RIDICULOUSLY_VERBOSE
	for (i = 0; i < 32; i += 2)
		printk("%sFR%02d : %016lx  FR%2d : %016lx", level, i,
				regs->fr[i], i+1, regs->fr[i+1]);
#endif

	cr30 = mfctl(30);
	cr31 = mfctl(31);
	printk("%s\n", level);
	printk("%sIASQ: " RFMT " " RFMT " IAOQ: " RFMT " " RFMT "\n",
	       level, regs->iasq[0], regs->iasq[1], regs->iaoq[0], regs->iaoq[1]);
	printk("%s IIR: %08lx    ISR: " RFMT "  IOR: " RFMT "\n",
	       level, regs->iir, regs->isr, regs->ior);
	printk("%s CPU: %8d   CR30: " RFMT " CR31: " RFMT "\n",
	       level, ((struct task_struct *)cr30)->processor, cr30, cr31);
	printk("%s ORIG_R28: " RFMT "\n", level, regs->orig_r28);
}
예제 #3
0
int main(int argc, const char * argv[])
{
    int i, j = 15, k = 1;
    i = (j++, k++);
    
#define SET_FLAG(N) (N) |= 1
#define BIT_POS(N)            ( 1U << (N) )
    
    // insert code here...
    printf("k = %d\n", SET_FLAG(i));
    printf("bit_ops = 0%X\n", BIT_POS(j));
    printbinary(j);
    return 0;
}
예제 #4
0
void farmerProblem() {

    int movers, i, location, newlocation;
    int route[16],temproute[16],temp=0;       //用于记录已考虑的状态路径
    //route数组的作用是储存位置状态的值,

    PSeqQueue moveTo;	//用于记录可以安全到达的中间状态

    moveTo = createEmptyQueue_seq( );//创建空队列
    enQueue_seq(moveTo, 0x00);	//初始状态进队列

    for (i = 0; i < 16; i++)
        route[i] = -1;

    //准备数组route初值
    route[0]=0;

    while (!isEmptyQueue_seq(moveTo)&&(route[15] == -1)) {
        location = frontQueue_seq(moveTo);		 //取队首状态为当前状态
        deQueue_seq(moveTo);
        for (movers = 1; movers <= 8; movers <<= 1) { //考虑各种物品移动
            if ((0 != (location & 0x08)) == (0 != (location & movers))) {	 //农夫与移动的物品在同一侧
                newlocation = location^(0x08|movers);	//异或计算新状态 如初始状态下为 0000^(1000|0001) = 1001
                if (safe(newlocation) && (route[newlocation] == -1)) {	//新状态安全且未处理
                    route[newlocation] = location;		//记录新状态的前驱
                    enQueue_seq(moveTo, newlocation);	//新状态入队
                }
            }
        }
    }
    //到达最终状态
    if(route[15] != -1) {
        printf("The reverse path is : \n");
        for(location = 15; location >= 0; location = route[location]) {
            temproute[temp]=location;
            ++temp;
            printf("The location is : %d\n",location);
            if (location == 0) {
                for(temp=7; temp>=0; --temp) {
                    //printf("%d\n",temproute[temp]);
                    printbinary(temproute[temp]);
                    printf("\n");
                }
                return;
            }
        }
    } else
        printf("No solution.\n");
}
예제 #5
0
int
main()
{
    fsysloc_table_t *fsystab;
    const fsysloc_t	*fsys;
    char	*oldloc;
    char	testdata[128];
    char	*outbuf;
    char	*inbuf;


    fsystab = fsysloc_table_init( "./fsysloc.conf");
    if ( fsystab==NULL) {
        fprintf( stderr, "fsysloc_table_init() error.\n");
        exit(1);
    }

    fsys = fsysloc_table_locate( fsystab, "sd:/root/whatever");

    if ( fsys==NULL) {
        fprintf( stderr, "unable to find sd:/ fsysloc_table_locate() error.\n");
        exit(1);
    }

    fsys = fsysloc_table_locate( fsystab, "usb:/root/whatever");

    if ( fsys==NULL) {
        fprintf( stderr, "unable to find usb:/ fsysloc_table_locate() error.\n");
        exit(1);
    }

    oldloc = fsysloc_setlocale( fsys);

    fsysloc_restorelocale( fsys, oldloc);


    sprintf( testdata, "smb2:/eMule/%s.rmvb", chinese);

    fsys = fsysloc_table_locate( fsystab, testdata);

    if ( fsys==NULL) {
        fprintf( stderr, "fsysloc_table_locate() error.\n");
        exit(1);
    }

    inbuf = testdata;
    outbuf = fsysloc_iconv_from_fsys( fsys, inbuf);
    printbinary( " inbuf_from_fsys:",  inbuf);
    printbinary( "outbuf_from_fsys:", outbuf);


    inbuf = outbuf;
    outbuf = fsysloc_iconv_to_fsys( fsys, inbuf);
    printbinary( "   inbuf_to_fsys:", inbuf);
    printbinary( "  outbuf_to_fsys:", outbuf);

    if ( strcmp( outbuf, testdata)==0) {
        printf( "YES ! they are equal.\n");
    } else {
        printf( "NO! continue to work....\n");
    }
    fsysloc_table_close( fsystab);
    return 0;

}
예제 #6
0
void main(){

 printbinary(7);
}
예제 #7
0
파일: derp.c 프로젝트: Hbrinj/Algorithms
int main(int argc, char** argv)
{
	printbinary(atoi(argv[1]));
}