void MemClrNoLog ( UINT32 addr,       //Memory Address
				   int total_byte,    //Number of Data to clear in Byte
				   UINT32 logaddr, 
				   int logbit                                        
				 )
{
	UINT32 result;
	int i,j=0;	

	for(i=0;i<total_byte;i=i+4)
	{
		set32(addr+(UINT32)i,0x0);
		result = read32(addr+(UINT32)i);
		if(result == 0x0)
		{ 
			j++; 
		}
		else
		{ 
			j=j; 
		}
	}
	if(j == total_byte/4)
	{
		setbits(logaddr, logbit, logbit, 1);
	}
	else
	{
		setbits(logaddr, logbit, logbit, 0);
	}

	return;
}
Example #2
0
int main(int argc, char const* argv[])
{
  setbits(1, 0, 1, 1);
  setbits(1, 1, 2, 1);
  setbits(1, 2, 3, 1);
  setbits(1, 3, 4, 1);
  setbits(1, 4, 5, 1);
  return 0;
}
static int r8a66597_clock_enable(struct r8a66597 *r8a66597)
{
	u16 tmp;
	int i = 0;

#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
	do {
		r8a66597_write(r8a66597, SCKE, SYSCFG0);
		tmp = r8a66597_read(r8a66597, SYSCFG0);
		if (i++ > 1000) {
			printf("register access fail.\n");
			return -1;
		}
	} while ((tmp & SCKE) != SCKE);
	r8a66597_write(r8a66597, 0x04, 0x02);
#else
	do {
		r8a66597_write(r8a66597, USBE, SYSCFG0);
		tmp = r8a66597_read(r8a66597, SYSCFG0);
		if (i++ > 1000) {
			printf("register access fail.\n");
			return -1;
		}
	} while ((tmp & USBE) != USBE);
	r8a66597_bclr(r8a66597, USBE, SYSCFG0);
#if !defined(CONFIG_RZA_USB)
	r8a66597_mdfy(r8a66597, CONFIG_R8A66597_XTAL, XTAL, SYSCFG0);

	i = 0;
	r8a66597_bset(r8a66597, XCKE, SYSCFG0);
	do {
		udelay(1000);
		tmp = r8a66597_read(r8a66597, SYSCFG0);
		if (i++ > 500) {
			printf("register access fail.\n");
			return -1;
		}
	} while ((tmp & SCKE) != SCKE);
#else
	/*
	 * RZ/A Only:
	 * Bits XTAL(UCKSEL) and UPLLE in SYSCFG0 for USB0 controls both USB0
	 * and USB1, so we must always set the USB0 register
	 */
#if (CONFIG_R8A66597_XTAL == 1)
	setbits(le16, R8A66597_BASE0, XTAL);
#endif
	mdelay(1);
	setbits(le16, R8A66597_BASE0, UPLLE);
	mdelay(1);
	r8a66597_bset(r8a66597, SUSPM, SUSPMODE0);
#endif /* CONFIG_RZA_USB */
#endif	/* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */

	return 0;
}
Example #4
0
int encode_number(char *msg, char *no) {
	unsigned int i;
	int digit;
	
	setbits(msg, 0, 2, 0);
	setbits(msg, 2, 8, strlen(no));
	for(i=0;i<strlen(no);i++)
		setbits(msg,10+i*4, 4, encode_digit(no[i]));
	return (10+i*4+7)/8;
}
Example #5
0
File: ex2-6.c Project: imwally/knr
int main() {

    unsigned int x = 0x4a;   /* 01001010 (74) */
    unsigned int y = 0x3c;   /* 00111100 (60) */

    printf("x: %x\n", x);
    printf("y: %x\n", y);
    
    /* setbits(x, 4, 4, y):
     *
     * x = 0  1  0  0  1  0  1  0
     *     7  6  5  4  3  2  1  0
     *              ^--------^
     *
     * The 4 bits that begin at position 4 must be set to the
     * rightmost 4 bits of y.
     *
     * y = 0  0  1  1  1  1  0  0
     *                 ^--------^
     *
     * These 4 bits should replace the 4 in x.
     *
     * x = 0  1  0  1  1  0  0  0
     *              ^--------^
     *
     * In decimal this is 88.
     */

    printf("setbits(x, 4, 4, y) = %d\n", setbits(x, 4, 4, y));

}
Example #6
0
  void init()
  {
    mColor = Color(0xFF,0xFF,0xFF);
    mLevel = 4;
    mCounter = 0;
    updatePrescalers();

    setbits(LED_DDR, LED_PINS); // output
  }
Example #7
0
int main()
{

	int x = 15;
	printf("%x\n", x & 0177);

	int b = 0177;
	printf("%o\n", ~b);
	printf("getbits:%x\n", getbits(0x3c7, 0, 1));
	printf("%x\n", setbits(1023, 5, 3, 128));
}
Example #8
0
/* Test stuff */
int main() {
    unsigned funbits = 0x01234678;
    printf("0x00000067 = 0x%08x\n"
           "0x01234f78 = 0x%08x\n"
           "0x0123..78 = 0x%08x\n"
           "0x67801234 = 0x%08x\n",
            getbits(funbits, 4, 8),
            setbits(funbits, 8, 4, 0xf),
            invbits(funbits, 8, 8),
            rightrot(funbits, 12)
          );
    return 0;
}
void MemCompNoLog ( UINT32 addr1, //Address 1
					UINT32 addr2, //Address 2
					UINT32 length, //Number of data to Check in Byte 
					UINT32 logaddr, 
					int logbit
				  )
{
	unsigned int i,j;
	UINT32 rdata1,rdata2;
	j=0;

	  //  RegBitWrite(logaddr, logbit, logbit, 0);
	
	for(i=0;i<length;i=i+4)
	{
		rdata1=read32(addr1+i);
		rdata2=read32(addr2+i);
		if(rdata1==rdata2)
		{
			j++;
		}
		else
		{
			j=j;
			break;
		}
	}
	if(j==length/4)
		setbits(logaddr, logbit, logbit, 1);
	else 
		setbits(logaddr, logbit, logbit, 0);
	
	j=0;
	
	return;
}
Example #10
0
int main(void)
{
  unsigned i = 0x57f7f5;;
  unsigned j = 0x7f;;
  unsigned k;
  int p = 32;
  int n = 8;

  k = setbits(i, p, n, j);

  print2bin( i );
  printf(" = %3u\n", i);
  print2bin( j );
  printf(" = %3u\n", j);
  print2bin( k );
  printf(" = %3u p = %d n = %d\n", k, p, n);

  return 0;
}
Example #11
0
int main(void)
{
  unsigned i;
  unsigned j;
  unsigned k;
  int p;
  int n;
  
  for(i = 0; i < 30000; i += 511)
  {
    for(j = 0; j < 1000; j += 37)
    {
      for(p = 0; p < 16; p++)
      {
        for(n = 1; n <= p + 1; n++)
        {
          k = setbits(i, p, n, j);
          printf("setbits(%u, %d, %d, %u) = %u\n", i, p, n, j, k);
        }
      }
    }
  }
  return 0;
}
Example #12
0
void encode_cdma_sms(char *pdu, char *to, char *message) {
	int i;
	int length;
	
	if(strlen(message)>160) LOGE("Error: Message String too long");
	for(i=0;i<512;i++)
		pdu[i]='0';
	setbits(pdu,0,16,0);
	setbits(pdu,16,24,0x021002);
	pdu=pdu+10;
	setbits(pdu,0,8,0x04);
	length=encode_number(pdu+4, to);
	setbits(pdu,8,8,length);
	pdu=pdu+length*2+4;
	setbits(pdu,0,24,0x060100);
	pdu=pdu+6;
	setbits(pdu,0,8,0x08);
	length=encode_bearer_data(pdu+4, message);
	if(length>255) LOGE("Error: Message Hex too long");
	setbits(pdu,8,8,length);
	pdu=pdu+length*2+4;
	*pdu=0;
}
Example #13
0
File: 2-06.c Project: aeihu/hacks
main()
{
    printf ("setbits(138, 5, 2, 138)=%d\n", setbits(138, 5, 2, 138));
}
Example #14
0
main()
{
    printf("%u\n",setbits(54,4,3,32));
    return 0;
}
Example #15
0
int encode_bearer_data(char *msg, char *data) {
	int msgid=0;
	unsigned int i;
        int b;
	char *start=msg;
	
	for(i=0;i<strlen(data);i++)
		msgid+=data[i];
		
	setbits(msg,0,8,0); // message id
	setbits(msg,8,8,3); // 3 bytes
	setbits(msg,16,4,2); // 2 means send
	setbits(msg,20,16,msgid); // use message sum for id
	msg+=10;
	setbits(msg,0,8,01); // user data
	setbits(msg,16,5,02); // set encoding
	setbits(msg,21,8,strlen(data)); // length
	b=29;
	for(i=0;i<strlen(data);i++) {
		setbits(msg,b,7,data[i]);
		b=b+7;
	}
	setbits(msg,8,8,(b+7)/8-2);
	msg=msg+2*((b+7)/8);
	setbits(msg,0,24,0x80100);
	setbits(msg,24,24,0x0D0100);
	msg=msg+12;
	return (msg-start)/2;
}
int cicom0_v500_trans_config(UINT32 src_addr, UINT32 des_addr, UINT32 num_8)
{	
    UINT32 i;
    
    UINT32 pdu_len;
    
    UINT32 alg_sel= 0x0 ;//gea3
    UINT32 cb     = 0x00;//cipher_cb 
    UINT32 ck1_1  = 0x2bb97c23;
    UINT32 ck1_2  = 0x76d0dbb8;
    UINT32 ck1_3  = 0x00000000;
    UINT32 ck1_4  = 0x00000000;
    UINT32 cc1    = 0x1f927f6c;
    
if(ck_addr == 0)
{
	ck_addr        = (UINT32)osl_cachedma_malloc(1024);
}
if(lli_prm == 0) 
{
	lli_prm        = (UINT32)osl_cachedma_malloc(1024);
}
    pdu_len = num_8*8;
    
    setbit(SYSCTRL_SCMISCCTRL, Cicom_sel ,0x1);//select W(0) / G(1)
    
    //cacheDisable(1);/*需要确认是否要实现,zuofenghua*/??
    
    // cfg the lli_param
    set32( (lli_prm + 0x00000000), ck_addr                      );//CK_ADDR              
    set32( (lli_prm + 0x00000004), cc1                          );//CC                   
    set32( (lli_prm + 0x00000008), pdu_len                      );//SRC_PDU_TOTAL_LEN    
    set32( (lli_prm + 0x0000000c), 0x00000002                   );//CUSTOM_CFG
    set32( (lli_prm + 0x00000010), src_addr                     );//LLI_SRC_PDU_SEG_ADDR 
    set32( (lli_prm + 0x00000014), des_addr                     );//LLI_DST_TTF_SEG_ADDR
    set32( (lli_prm + 0x00000018), 0x00000000                   );//LLI_DST_MBX_SEG_ADDR
    set32( (lli_prm + 0x0000001c), 0x00000000                   );//LLI_PRM_ADDR      
 
    // cfg the key_data
    set32( (ck_addr + 0x00000000), ck1_1);
    set32( (ck_addr + 0x00000004), ck1_2);
    set32( (ck_addr + 0x00000008), ck1_3);
    set32( (ck_addr + 0x0000000c), ck1_4);
    
    //set registers
    set32(asicCICOMPRIOR_SELECT     , 0x00000000           );
    set32(asicCICOMLLI_PARAM_ADDR_DL, lli_prm              );
    setbits(asicCICOMGLOBAL_CFG_DL  , 1, 0, alg_sel        );  
    setbits(asicCICOMGLOBAL_CFG_DL  , 11, 8, 0x0           );  
    setbits(asicCICOMGLOBAL_CFG_DL  , 20, 16, cb           );  
    set32(asicCICOMINT_EN_DL        , 0x00000000           );//int enable
    //set32(asicCICOMEN_DL            , 0x00000001           );//start cicom
    
    // initial memory
	for( i = 0; i < num_8/4; i++ )
	{
		set32( src_addr+0x4*i, 0x5a5a5a5a+i );
		set32( des_addr+0x4*i, 0x0 );
	}
	
	return 0;
}
Example #17
0
File: bp.cpp Project: rkonow/topk
void make_matchtbl(void)
{
    i64 i,j,x,r;
    i64 m,M;
    pb buf[1];
    i64 deg;

    for (x = 0; x < (1<<ETW); x++) {
        setbits(buf,0,ETW,x);
        for (r=-ETW; r<=ETW; r++) fwdtbl[((r+ETW)<<ETW)+x] = ETW;
        for (r=-ETW; r<=ETW; r++) bwdtbl[((r+ETW)<<ETW)+x] = ETW;
        for (r=-ETW; r<=ETW; r++) degtbl2[((r+ETW)<<ETW)+x] = 0;
        for (r=-ETW; r<=ETW; r++) depthtbl[((r+ETW)<<ETW)+x] = 0;

        r = 0;
        for (i=0; i<ETW; i++) {
            if (getbit(buf,i)==OP) {
                r++;
            } else {
                r--;
            }
            if (fwdtbl[((r+ETW)<<ETW)+x] == ETW) fwdtbl[((r+ETW)<<ETW)+x] = i;
        }

        r = 0;
        for (i=ETW-1; i>=0; i--) {
            if (getbit(buf,i)==OP) {
                r--;
            } else {
                r++;
            }
            if (bwdtbl[((r+ETW)<<ETW)+x] == ETW) bwdtbl[((r+ETW)<<ETW)+x] = ETW-1-i;
        }

        r = 0;
        for (i=0; i<ETW; i++) {
            if (getbit(buf,i)==OP) {
                r++;
            } else {
                r--;
            }
            depthtbl[((r+ETW)<<ETW)+x] += (1<<(ETW-1));
        }

        r = 0;
        for (i=0; i<ETW; i++) {
            if (getbit(buf,i)==OP) r++;
        }
        popCount[x] = r;

        r = 0;
        m = 0;
        M = 0;
        m = ETW+1;
        M = -ETW-1;
        //maxtbl_lv[x] = -ETW-1;
        //mi64bl_lv[x] = ETW+1;
        minmaxtbl_v[OPT_MAX | OPT_LEFT][x] = -ETW-1;
        minmaxtbl_v[OPT_MIN | OPT_LEFT][x] = ETW+1;
        deg = 0;
        for (i=0; i<ETW; i++) {
            if (getbit(buf,i)==OP) {
                r++;
                if (r > M) {
                    M = r;
                    //maxtbl_li[x] = i;  maxtbl_lv[x] = r;
                    minmaxtbl_i[OPT_MAX | OPT_LEFT][x] = i;
                    minmaxtbl_v[OPT_MAX | OPT_LEFT][x] = r;
                }
            } else {
                r--;
                if (r == m) {
                    deg++;
                    childtbl[((deg-1)<<ETW) + x] = i;
                }
                if (r < m) {
                    m = r;
                    //mi64bl_li[x] = i;  mi64bl_lv[x] = r;
                    minmaxtbl_i[OPT_MIN | OPT_LEFT][x] = i;
                    minmaxtbl_v[OPT_MIN | OPT_LEFT][x] = r;
                    deg = 1;
                    childtbl[((deg-1)<<ETW) + x] = i;
                }
            }
            if (r <= m) degtbl2[((r+ETW)<<ETW)+x]++;
        }
        degtbl[x] = deg;

        r = 0;
        m = 0;
        M = 0;
        //maxtbl_rv[x] = -ETW-1;
        //mi64bl_rv[x] = ETW+1;
        minmaxtbl_v[OPT_MAX | OPT_RIGHT][x] = -ETW-1;
        minmaxtbl_v[OPT_MIN | OPT_RIGHT][x] = ETW+1;
        for (i=0; i<ETW; i++) {
            if (getbit(buf,i)==OP) {
                r++;
                if (r >= M) {
                    M = r;
                    //maxtbl_ri[x] = i;  maxtbl_rv[x] = r;
                    minmaxtbl_i[OPT_MAX | OPT_RIGHT][x] = i;
                    minmaxtbl_v[OPT_MAX | OPT_RIGHT][x] = r;
                }
            } else {
                r--;
                if (r <= m) {
                    m = r;
                    //mi64bl_ri[x] = i;  mi64bl_rv[x] = r;
                    minmaxtbl_i[OPT_MIN | OPT_RIGHT][x] = i;
                    minmaxtbl_v[OPT_MIN | OPT_RIGHT][x] = r;
                }
            }
        }

        for (i = 0; i < ETW; i++) {
            for (j = -ETW; j <= ETW; j++) {
                childtbl2[j+ETW][i][x] = -1;
            }
        }

        for (j=-ETW; j<=ETW; j++) {
            i64 ith;
            ith = 0;
            r = 0;
            for (i = 0; i < ETW; i++) {
                if (getbit(buf,i)==OP) {
                    r++;
                } else {
                    r--;
                    if (r < j) break;
                    if (r == j) {
                        ith++;
                        childtbl2[j+ETW][ith-1][x] = i;
                    }
                }
            }
        }
    }

}