Beispiel #1
0
void bsw_0_has_data_handler()
{
	getfsl(iptr3[tmp], 2);
	getfsl(iptr3[tmp+1], 2);
	tmp += 2;
	if(tmp >= items) running = 0;
}
Beispiel #2
0
int main()
{
    init_platform();

    xil_printf("%s\n\r", "Welcome to Brutus cracker system!");

    while (1) {
    	xil_printf("%s\n\r", "Enter hash: ");
		char recv = XUartLite_RecvByte(STDIN_BASEADDRESS); // read first char


		/* Read password hash */
		char buff[32];
		int idx_buff = 0;
		while (recv != '\r') {
			buff[idx_buff++] = recv;
			recv = XUartLite_RecvByte(STDIN_BASEADDRESS);
		}

		unsigned int i_buff[4] = {0};
		unsigned num = 0;

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 8; j++) {
				num = ctox(buff[j + i*8]);
				i_buff[i] += (pow(16, 7-j) * num);
			}
			//xil_printf("%x\n\r", i_buff[i]);
		}

		//xil_printf("%u\n\r", i_buff[0]);


		putfsl(i_buff[0], 0);
		putfsl(i_buff[1], 0);
		putfsl(i_buff[2], 0);
		putfsl(i_buff[3], 0);
		xil_printf("Cracking...\n\r");

		unsigned int resp;
		char *str = &resp; // c-magic

		getfsl(resp, 0);
		unsigned i;
		xil_printf("password: "******"%c", *(str+i));
		}
		getfsl(resp, 0);
		for (i = 0; i < 4; i++) {
			xil_printf("%c", *(str+i));
		}
		xil_printf("\n\r");
    }
    cleanup_platform();

    return 0;
}
Beispiel #3
0
int main (void)
{
    float u[n*n], v[n*n], u0[n*n], v0[n*n];
    float x, y, x0, y_0, f, r, U[2], V[2], s, t;
    int i, j, i0, j_0, i1, j_1,m;
    int k;
    float visc=1.25;
    float dt=2.36;
    int start,end;
    
    xil_printf("----------------------- START ------------------------ ! \n\r");
    int MASK_LENGTH= 10;//(int) ceil((log(BUFFER_SIZE))/log(2));
    int MASK = ((1 << MASK_LENGTH)-1);

    //-- Flag Initializations
    for (i=0; i<BUFFER_SIZE; i++)
    {
        flag1[i]=0;
        flag2[i]=0;
        flag3[i]=0;
    }
    

    XTmrCtr timer;
    XTmrCtr_Initialize(&timer, XPAR_XPS_TIMER_0_DEVICE_ID);

    XTmrCtr_Reset(&timer, TIMER_COUNTER_0);
    start = XTmrCtr_GetValue(&timer, TIMER_COUNTER_0);

    // Start timer
    XTmrCtr_Start(&timer, TIMER_COUNTER_0);

    //------- LOOP FOR IMAGES -------
    for (k=0; k < Number_of_Images; k++)  // loop for Images 
    {
	  consumer_index = ci; // for nested loop can be i*n+j

        while (consumer_index<SIZE_floid)
        {

            
            if (read_from_fifo ==1)
            {
                getfsl(fifo_index,0);
                if (fifo_index!=999999999) 
                {    						
                    getfsl(fifo_data,0);
                    getfsl(fifo_data2,0);
                    xil_printf("READ %d FROM FIFO \t",fifo_index);
                    
                    if (consumer_index == fifo_index && fifo_index!=999999999)
                    {   
                        // consume the data directly				
                        consumer_data = fifo_data;
                        consumer_data2 = fifo_data2;
                        xil_printf("»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» %d DIRECTLY CONSUMED !\n\r",consumer_index);
                        
                        consumer_index=consumer_index+1;//ci;
								consumer_done=1;
                        read_from_fifo=1;
                        //-- The rest of consumer's computing stage here   : output: consumer_index
                        u0[i+(n+2)*j] = consumer_data;  // u[i+n*j]
                        v0[i+(n+2)*j] = consumer_data2;  // v[i+n*j]
                        y = j<=n/2 ? j : j-n;
                        r = x*x+y*y;
                        if ( r==0.0 ) continue;
                        f = exp(-r*dt*visc);
                        U[0] = u0[i +(n+2)*j]; 
                        V[0] = v0[i +(n+2)*j];
                        U[1] = u0[i+1+(n+2)*j]; 
                        V[1] = v0[i+1+(n+2)*j];
                        u0[i +(n+2)*j] = f*( (1-x*x/r)*U[0] -x*y/r *V[0] );
                        u0[i+1+(n+2)*j] = f*( (1-x*x/r)*U[1] -x*y/r *V[1] );
                        v0[i+ (n+2)*j] = f*( -y*x/r *U[0] + (1-y*y/r)*V[0] );
                        v0[i+1+(n+2)*j] = f*( -y*x/r *U[1] + (1-y*y/r)*V[1] );
                        
                        
                    }

                }
						else  if (fifo_index==999999999)
							{
							xil_printf("==PRODUCER STOPPED AND consumer_index IS %d!\n\r",consumer_index);
							read_from_fifo=0; 
							//consumer_index++;
							}  
				}			
               
                    // compute the hash
                    consumer_hash_index = consumer_index & MASK;   // here index is not refreshing
                    fifo_hash_index = fifo_index & MASK;
                    
                    // Load from memory
                    if (flag1[consumer_hash_index]==1 && index1[consumer_hash_index]==consumer_index)
                    {
                        flag1[consumer_hash_index]=0;
                        consumer_data= data1[consumer_hash_index];

                        xil_printf("========== LOAD consumer_index %d from T1 ================!\n\r",consumer_index);
								consumer_index++;
								consumer_done=1;
                        //-- The rest of consumer's computing stage here : output: consumer_index
                        u0[i+(n+2)*j] = consumer_data;  // u[i+n*j]
                        v0[i+(n+2)*j] = consumer_data2;  // v[i+n*j]
                        y = j<=n/2 ? j : j-n;
                        r = x*x+y*y;
                        if ( r==0.0 ) continue;
                        f = exp(-r*dt*visc);
                        U[0] = u0[i +(n+2)*j]; 
                        V[0] = v0[i +(n+2)*j];
                        U[1] = u0[i+1+(n+2)*j]; 
                        V[1] = v0[i+1+(n+2)*j];
                        u0[i +(n+2)*j] = f*( (1-x*x/r)*U[0] -x*y/r *V[0] );
                        u0[i+1+(n+2)*j] = f*( (1-x*x/r)*U[1] -x*y/r *V[1] );
                        v0[i+ (n+2)*j] = f*( -y*x/r *U[0] + (1-y*y/r)*V[0] );
                        v0[i+1+(n+2)*j] = f*( -y*x/r *U[1] + (1-y*y/r)*V[1] );
								

								if (fifo_index!=999999999) 
									read_from_fifo=1;
							

                    }
                    else if (flag2[consumer_hash_index]==1 && index2[consumer_hash_index]==consumer_index)
                    {
                        flag2[consumer_hash_index]=0;
                        consumer_data= data2[consumer_hash_index];
                       consumer_index++;
                        read_from_fifo=1;
                        consumer_done=1;
                        xil_printf("=================== LOAD consumer_index %d from T2 ================!\n\r",consumer_index);
                        //-- The rest of consumer's computing stage here  : output: consumer_index
                        u0[i+(n+2)*j] = consumer_data;  // u[i+n*j]
                        v0[i+(n+2)*j] = consumer_data2;  // v[i+n*j]
                        y = j<=n/2 ? j : j-n;
                        r = x*x+y*y;
                        if ( r==0.0 ) continue;
                        f = exp(-r*dt*visc);
                        U[0] = u0[i +(n+2)*j]; 
                        V[0] = v0[i +(n+2)*j];
                        U[1] = u0[i+1+(n+2)*j]; 
                        V[1] = v0[i+1+(n+2)*j];
                        u0[i +(n+2)*j] = f*( (1-x*x/r)*U[0] -x*y/r *V[0] );
                        u0[i+1+(n+2)*j] = f*( (1-x*x/r)*U[1] -x*y/r *V[1] );
                        v0[i+ (n+2)*j] = f*( -y*x/r *U[0] + (1-y*y/r)*V[0] );
                        v0[i+1+(n+2)*j] = f*( -y*x/r *U[1] + (1-y*y/r)*V[1] );

                    }
                    else if (flag3[consumer_hash_index]==1 && index3[consumer_hash_index]==consumer_index)
                    {
                        flag3[consumer_hash_index]=0;
                        consumer_data= data3[consumer_hash_index];
                        consumer_index++;
                        read_from_fifo=1;
                        consumer_done=1;
								consumer_done=1;
                        xil_printf("=================== LOAD consumer_index %d from T3 ================!\n\r",consumer_index);
                        //-- The rest of consumer's computing stage here : output: consumer_index
                        u0[i+(n+2)*j] = consumer_data;  // u[i+n*j]
                        v0[i+(n+2)*j] = consumer_data2;  // v[i+n*j]
                        y = j<=n/2 ? j : j-n;
                        r = x*x+y*y;
                        if ( r==0.0 ) continue;
                        f = exp(-r*dt*visc);
                        U[0] = u0[i +(n+2)*j]; 
                        V[0] = v0[i +(n+2)*j];
                        U[1] = u0[i+1+(n+2)*j]; 
                        V[1] = v0[i+1+(n+2)*j];
                        u0[i +(n+2)*j] = f*( (1-x*x/r)*U[0] -x*y/r *V[0] );
                        u0[i+1+(n+2)*j] = f*( (1-x*x/r)*U[1] -x*y/r *V[1] );
                        v0[i+ (n+2)*j] = f*( -y*x/r *U[0] + (1-y*y/r)*V[0] );
                        v0[i+1+(n+2)*j] = f*( -y*x/r *U[1] + (1-y*y/r)*V[1] );
								

                    }
                    // Store in memory
                    else if (read_from_fifo ==1 && consumer_done==0) 
                    {
							 
                        if (flag1[fifo_hash_index]==0 && fifo_index!=999999999)
                        {
                            data1[fifo_hash_index] =fifo_data; 
                            index1[fifo_hash_index] =fifo_index;
                            flag1[fifo_hash_index]=1;
                            read_from_fifo=1;									 
                            xil_printf("»»»»»»»»»»»»»»»»»%d STORED in T1 \n\r",fifo_index);
                        }
                        else if (flag2[fifo_hash_index]==0 && fifo_index!=999999999)
                        {
                            data2[fifo_hash_index] =fifo_data;
                            index2[fifo_hash_index] =fifo_index;						  
                            flag2[fifo_hash_index]=1;
                            read_from_fifo=1;
                            xil_printf("»»»»»»»»»»»»»»»»»%d STORED in T2 \n\r",fifo_index);
                        }
                        else if (flag3[fifo_hash_index]==0 && fifo_index!=999999999)
                        {
                            data3[fifo_hash_index] =fifo_data;
                            index3[fifo_hash_index] =fifo_index;
                            flag3[fifo_hash_index]=1;
                            read_from_fifo=1;
                            xil_printf("»»»»»»»»»»»»»»»»»%d STORED in T3 \n\r",fifo_index);
                        }
                        else
                        read_from_fifo=0;
							
                        
                    } // Store in memory						  
						  else
						  {
							xil_printf("ERROR ! Index %d cannot be found !!!!\n\r",consumer_index);
							consumer_done=0;
							consumer_index++;
							}
                
            
        }
    }
    xil_printf ("consumer_index =%d \t ci=%d \n\r",consumer_index,ci);
    end = XTmrCtr_GetValue(&timer, TIMER_COUNTER_0);
    XTmrCtr_Stop(&timer, TIMER_COUNTER_0);
    xil_printf("Timer Start value = %d    Timer end value = %d \r\n", start, end-start);
    return 0;
}
Beispiel #4
0
int main (void) 
{
   
//------- LOOP FOR IMAGES -------
	for (m=0; m < Number_of_Images; m++)  // loop for Images 
	{
	getfsl(id1,0);	                       // Start Signal			
	
  //void fdct_8x8(short dct_data, unsigned num_fdcts)  
                   
  /* -------------------------------------------------------- /    
     /  Set up the cosine coefficients c0..c7.                  /    
     / -------------------------------------------------------- */    
  const unsigned short c1 = 0x2C62, c3 = 0x25A0;                    
  const unsigned short c5 = 0x1924, c7 = 0x08D4;                    
  const unsigned short c0 = 0xB505, c2 = 0x29CF;                    
  const unsigned short c6 = 0x1151;                                 
                                                                           
  /* -------------------------------------------------------- /    
     /  Intermediate calculations.                              /    
     / -------------------------------------------------------- */    
  short f0, f1, f2, f3,f4, f5, f6, f7;       // Spatial domain samples.       
  int   g0, g1, h0, h1,p0, p1;               // Even-half intermediate.     
  short r0, r1;               // Even-half intermediate.     
  int   P0, P1, R0, R1;       // Even-half intermediate.         
  short g2, g3, h2, h3;       // Odd-half intermediate.           
  short q0a,s0a,q0, q1,s0, s1;               // Odd-half intermediate.          
  short Q0, Q1, S0, S1;       // Odd-half intermediate.       
  int   F0, F1, F2, F3, F4, F5, F6, F7;       // Freq. domain results. 
  int   F0r,F1r,F2r,F3r,F4r,F5r,F6r,F7r;      // Rounded, truncated results.   
  
  /* -------------------------------------------------------- /    
     /  Input and output pointers, loop control.                /    
     / -------------------------------------------------------- */    
  unsigned i, j, i_1;                                                  
        
  
  #ifdef chksum
/* initilize the input image */
 for (i = 0; i < num_fdcts*M; i++) 
    dct_io_ptr[i] = i;   
#endif	

 
		 
  /* -------------------------------------------------------- /    
     /  Outer vertical loop -- Process each 8x8 block.          /    
     / -------------------------------------------------------- */    
  //dct_io_ptr = dct_data;    
  i_1 = 0;
  for (i = 0; i < num_fdcts; i++) {      
 
    /* ---------------------------------------------------- /    
       /  Perform Vert 1-D FDCT on columns within each block. /    
       / ---------------------------------------------------- */    
    for (j = 0; j < N; j++) {                                                             
      /* ------------------------------------------------ /    
	 /  Load the spatial-domain samples.                /    
	 / ------------------------------------------------ */    
      f0 = dct_io_ptr[ 0+i_1];                                      
      f1 = dct_io_ptr[ 8+i_1];                                      
      f2 = dct_io_ptr[16+i_1];                                      
      f3 = dct_io_ptr[24+i_1];                                      
      f4 = dct_io_ptr[32+i_1];                                      
      f5 = dct_io_ptr[40+i_1];                                      
      f6 = dct_io_ptr[48+i_1];                                      
      f7 = dct_io_ptr[56+i_1];                                      
                                                                           
      /* ------------------------------------------------ /    
	 /  Stage 1:  Separate into even and odd halves.    /    
	 / ------------------------------------------------ */    
      g0 = f0 + f7;               h2 = f0 - f7;                 
      g1 = f1 + f6;               h3 = f1 - f6;                 
      h1 = f2 + f5;               g3 = f2 - f5;                 
      h0 = f3 + f4;               g2 = f3 - f4;                 
      
      /* ------------------------------------------------ /    
	 /  Stage 2                                         /    
	 / ------------------------------------------------ */    
      p0 = g0 + h0;               r0 = g0 - h0;                 
      p1 = g1 + h1;               r1 = g1 - h1;                 
      q1 = g2;                    s1 = h2;                      
      
      s0a= h3 + g3;               q0a= h3 - g3;                   
      s0 = (s0a * c0 + 0x7FFF) >> 16;                           
      q0 = (q0a * c0 + 0x7FFF) >> 16;                           
                                                                           
      /* ------------------------------------------------ /    
	 /  Stage 3                                         /    
	 / ------------------------------------------------ */    
      P0 = p0 + p1;             P1 = p0 - p1;                 
      R1 = c6 * r1 + c2 * r0;     R0 = c6 * r0 - c2 * r1;       
      
      Q1 = q1 + q0;               Q0 = q1 - q0;                 
      S1 = s1 + s0;               S0 = s1 - s0;                 
      
      /* ------------------------------------------------ /    
	 /  Stage 4                                         /    
	 / ------------------------------------------------ */    
      F0 = P0;                    F4 = P1;                      
      F2 = R1;                    F6 = R0;                      
      
      F1 = c7 * Q1 + c1 * S1;     F7 = c7 * S1 - c1 * Q1;       
      F5 = c3 * Q0 + c5 * S0;     F3 = c3 * S0 - c5 * Q0;        
      
      /* ------------------------------------------------ /    
	 /  Store the frequency domain results.             /    
	 / ------------------------------------------------ */    
	
		
	 putfsl(0+i_1, 0);
	putfsl(F0, 0);
	
	putfsl(8+i_1, 0);
	putfsl(F1 >> 13, 0);
	
	putfsl(16+i_1, 0);
	putfsl(F2 >> 13, 0);
	
	putfsl(24+i_1, 0);
	putfsl(F3 >> 13, 0);
	
	putfsl(32+i_1, 0);
	putfsl(F4, 0);

	putfsl(40+i_1, 0);
	putfsl(F5 >> 13, 0);

	putfsl(48+i_1, 0);
	putfsl(F6 >> 13, 0);

	putfsl(56+i_1, 0);
	putfsl(F7 >> 13, 0);

	i_1++;                                            
    }                                                             
    /* ---------------------------------------------------- /    
    /  Update pointer to next 8x8 FDCT block.              /    
   / ---------------------------------------------------- */    
   i_1 += 56;                                    
  }
 putfsl(999999999,0);					 // Stop Signal
}  
 	
  
   return 0;
} 
Beispiel #5
0
void icap_reset(int resetProduction)
{
	unsigned long int fpga_base;
	u32 val;

	// ICAP behavior is described (poorly) in Xilinx specification UG380.  Brave
	// souls may look there for detailed guidance on what is being done here.
	fpga_base = (resetProduction != 0) ? RUNTIME_FPGA_BASE : BOOT_FPGA_BASE;
#ifdef CONFIG_SYS_GPIO
	if ((rdreg32(CONFIG_SYS_GPIO_ADDR) &
			(GARCIA_FPGA_LX100_ID | GARCIA_FPGA_LX150_ID)) == GARCIA_FPGA_LX150_ID) {
		fpga_base = BOOT_FPGA_BASE;
	}
#endif

	// It has been empirically determined that ICAP FSL doesn't always work
	// the first time, but if retried enough times it does eventually work.
	// Thus we keep hammering the operation we want and checking for failure
	// until we finally succeed.  Somebody please fix ICAP!! <sigh>

	// Abort anything in progress
	do {
		putfslx(0x0FFFF, 0, FSL_CONTROL); // Control signal aborts, data doesn't matter
		udelay(1000);
		getfsl(val, 0); // Read the ICAP result
	} while ((val & ICAP_FSL_FAILED) != 0);

	do {
		// Synchronize command bytes
		putfsl(0x0FFFF, 0); // Pad words
		putfsl(0x0FFFF, 0);
		putfsl(0x0AA99, 0); // SYNC
		putfsl(0x05566, 0); // SYNC

#ifndef CONFIG_SPI_FLASH
		// Set the Mode register so that fallback images will be manipulated
		// correctly.  Use bitstream mode instead of physical mode (required
		// for configuration fallback) and set boot mode for BPI
		putfsl(0x03301, 0); // Write MODE_REG
		putfsl(0x02000, 0); // Value 0 allows u-boot to use production image
#endif
		// Write the reconfiguration FPGA offset; the base address of the
		// "run-time" FPGA is #defined as a byte address, but the ICAP needs
		// a 16-bit half-word address, so we shift right by one extra bit.
#ifdef CONFIG_SPI_FLASH
		putfsl(0x03261, 0); // Write GENERAL1
		putfsl(((fpga_base >> 0) & 0x0FFFF), 0); // Multiboot start address[15:0]
		putfsl(0x03281, 0); // Write GENERAL2
		putfsl((((fpga_base >> 16) & 0x0FF) | 0x0300), 0); // Opcode 0x00 and address[23:16]

		// Write the fallback FPGA offset (this image)
		putfsl(0x032A1, 0); // Write GENERAL3
		putfsl(((BOOT_FPGA_BASE >> 0) & 0x0FFFF), 0);
		putfsl(0x032C1, 0); // Write GENERAL4
		putfsl((((BOOT_FPGA_BASE >> 16) & 0x0FF) | 0x0300), 0);
#else
		putfsl(0x03261, 0); // Write GENERAL1
		putfsl(((fpga_base >> 1) & 0x0FFFF), 0); // Multiboot start address[15:0]
		putfsl(0x03281, 0); // Write GENERAL2
		putfsl(((fpga_base >> 17) & 0x0FF), 0); // Opcode 0x00 and address[23:16]

		// Write the fallback FPGA offset (this image)
		putfsl(0x032A1, 0); // Write GENERAL3
		putfsl(((BOOT_FPGA_BASE >> 1) & 0x0FFFF), 0);
		putfsl(0x032C1, 0); // Write GENERAL4
		putfsl(((BOOT_FPGA_BASE >> 17) & 0x0FF), 0);
#endif

		putfsl(0x032E1, 0); // Write GENERAL5
		putfsl((resetProduction ? 1 : 0), 0); // Value 0 allows u-boot to use production image

		// Write IPROG command
		putfsl(0x030A1, 0); // Write CMD
		putfsl(0x0000E, 0); // IPROG Command

		// Add some safety noops
		putfsl(0x02000, 0); // Type 1 NOP
		putfsl(FINISH_FSL_BIT | 0x02000, 0); // Type 1 NOP, and Trigger the FSL peripheral to drain the FIFO into the ICAP
		__udelay (1000);
		getfsl(val, 0); // Read the ICAP result
	} while ((val & ICAP_FSL_FAILED) != 0);

	return;
}