uint8_t trilaterate( uint8_t i1, uint8_t i2, uint8_t i3 ){

	
	double x_1, y_1;
	double x_2, y_2;
	double x_3, y_3;

	double r1, r2, r3;

	double dsq, gam;
	double xa, ya, xb, yb;
	double xt1, yt1;
	double xt2, yt2;
	double d1, d2;

	// get positions of anchor
	
	x_1 = anchor[i1].x;
	y_1 = anchor[i1].y;

	x_2 = anchor[i2].x;
	y_2 = anchor[i2].y;

	x_3 = anchor[i3].x;
	y_3 = anchor[i3].y;

	r1 = anchor[i1].d;
	r2 = anchor[i2].d;
	r3 = anchor[i3].d;

	// Find the two intersection points of the two circles

	dsq = square(x_2-x_1) + square(y_2-y_1);
	gam = (square(r2+r1) - dsq) * (dsq - square(r2-r1));
#ifdef __DEBUG_MODE__
	dbg( 1, anchor[i1].id, x_1, y_1, r1 );
	dbg( 2, anchor[i2].id, x_2, y_2, r2 );
	dbg( 3, anchor[i3].id, x_3, y_3, r3 );
	dbg_out();
//	dbg( 1, 364, r1, r2, r3 );
//	dbg( 2, 370, dsq, square(x_2-x_1), square(y_2-y_1) );
//	dbg( 3, 371, gam, (square(r2+r1) - dsq), (dsq - square(r2-r1)) );
//	dbg_out();
#endif
	
	if( gam < 0 || dsq <=0 ){
		return ERROR_NONINTERSECT;
	}

	gam = sqrtd( gam );

	xa = -(square(r2) - square(r1)) * (x_2-x_1)/(2.0 * dsq) + (x_1+x_2)*0.5;
	ya = -(square(r2) - square(r1)) * (y_2-y_1)/(2.0 * dsq) + (y_1+y_2)*0.5;

	xb = (y_2-y_1) * gam/(2.0*dsq);
	yb = (x_2-x_1) * gam/(2.0*dsq);

	xt1 = xa - xb;
	xt2 = xa + xb;
	yt1 = ya + yb;
	yt2 = ya - yb;


	// disambiguate between the two points using the third node
	d1 = sqrtd( square( xt1 - x_3 ) + square( yt1 - y_3 ));
	d2 = sqrtd( square( xt2 - x_3 ) + square( yt2 - y_3 ));

	if( dabs( d1 - r3 ) < dabs( d2 - r3 ) ){
		delta_x = xt1;
		delta_y = yt1;
	}
	else {
		delta_x = xt2;
		delta_y = yt2;
	}

	return 0;

}
Esempio n. 2
0
/** 暗号化されたメッセージを解析し, 以下の情報を取り出す.
 *  - 通信に使用した暗号種別を表す暗号ケイパビリティ
 *  - 本文の暗号化に使用した鍵(hex形式)
 *  - 暗号化された本文(hex形式)
 *  - 署名(hex形式)
 *  @param[in]   message        暗号化されたメッセージ
 *  @param[out]  this_cap_p     通信に使用した暗号種別を表す暗号ケイパビリティ返却領域
 *  @param[out]  hex_skey_p     本文の暗号化に使用した鍵を指すポインタ変数のアドレス
 *  @param[out]  enc_message_p  暗号化された本文を指すポインタ変数のアドレス
 *  @param[out]  hex_sign_p     署名を指すポインタ変数のアドレス
 *  @retval  0       正常終了
 *  @retval -EINVAL  引数異常(buffがNULL)
 *                  
 *  @attention 内部リンケージ
 */
static int
parse_encrypted_message(const unsigned char *message,
		      unsigned long *this_cap_p,
		      unsigned char **hex_skey_p,
		      unsigned char **enc_message_p,
		      unsigned char **hex_sign_p){
	int                     rc = 0;
	char                   *sp = 0;
	char                   *ep = 0;
	unsigned long     this_cap = 0;
	unsigned char    *hex_skey = NULL;
	unsigned char *enc_message = NULL;
	unsigned char    *hex_sign = NULL;
	char                 *buff = NULL;

	if ( (message == NULL) || (this_cap_p == NULL) || (hex_skey_p == NULL) || (enc_message_p == NULL) ) {
		rc = -EINVAL;
		goto error_out;
	}

	rc = -ENOMEM;
	buff = g_strdup(message);
	if (buff == NULL)
		goto error_out;
	/*
	 * 鍵情報
	 */
	sp = buff;
	ep = strchr(sp, ':');
	if (ep == NULL) {
		rc = -EINVAL;
		err_out("Error : No cap\n");
		goto free_buff_out;
	}
	*ep = '\0';
	++ep;
	errno = 0;
	this_cap = strtoul(sp, (char **)NULL, 16);
	dbg_out("Cap:0x%x\n", this_cap);

	/*
	 *暗号鍵
	 */
	sp = ep;
	ep = strchr(sp, ':');
	if (ep == NULL) {
		rc = -EINVAL;
		err_out("Error : crypt key\n");
		goto free_buff_out;
	}
	*ep = '\0';
	++ep;
	rc = -ENOMEM;
	hex_skey = g_strdup(sp);
	if (hex_skey == NULL)
		goto free_buff_out;
	dbg_out("hex secret key:%s\n", hex_skey);

	
	/*
	 * 暗号化本文
	 */
	sp = ep;
	ep = strchr(sp, ':');
	if (ep != NULL) { /* これで最後の可能性もある  */
		*ep = '\0';
		++ep;
	}
	rc = -ENOMEM;
	enc_message = g_strdup(sp);
	if (enc_message == NULL)
		goto free_hex_skey_out;

	dbg_out("hex secret body:%s\n", enc_message);

	/*
	 * 署名
	 */
	if (ep != NULL) {
		sp = ep;
		rc = -ENOMEM;
		hex_sign = g_strdup(sp);
		if (hex_sign == NULL)
			goto free_enc_message_out;
		dbg_out("hex sign:%s\n", hex_sign);
	}

	/*
	 * 返却
	 */

	*this_cap_p    = this_cap;
	*hex_skey_p    = hex_skey;
	*enc_message_p = enc_message;
	*hex_sign_p    = hex_sign;
	if (buff != NULL)
		g_free(buff);

	return 0;

free_enc_message_out:
	if (enc_message != NULL)
		g_free(enc_message);

free_hex_skey_out:
	if (hex_skey != NULL)
		g_free(hex_skey);

free_buff_out:
	if (buff != NULL)
		g_free(buff);

error_out:
	return rc;
}
Esempio n. 3
0
void init_pctl(void)
{
	int nTempVal;
	int stat;
  
	MMC_Wr(MMC_PHY_CTRL,v_mmc_phy_ctrl);
/*	MMC_Wr(UPCTL_DLLCR9_ADDR, v_dllcr9); //2a8	
	MMC_Wr(UPCTL_IOCR_ADDR, v_iocr); //248
	MMC_Wr(UPCTL_PHYCR_ADDR, 2);//????
*/

  //wait to DDR PLL lock.
	//while (!(MMC_Rd(MMC_CLK_CNTL) & (1<<29)) ) {}
	//dbg_out("d",1);
  //Enable DDR DLL clock input from PLL.
//     MMC_Wr(MMC_CLK_CNTL, 0xc0000080);  //  @@@ select the final mux from PLL output directly.
//     MMC_Wr(MMC_CLK_CNTL, 0xc00000c0);    
    //enable the clock.
	//MMC_Wr(MMC_CLK_CNTL, v_mmc_clk_cntl);
     
    // release the DDR DLL reset pin.
//    MMC_Wr( MMC_SOFT_RST,  0xffff);
	//__udelay(10);
	//UPCTL memory timing registers
	MMC_Wr(UPCTL_TOGCNT1U_ADDR, v_t_1us_pck);	 //1us = nn cycles.
	MMC_Wr(UPCTL_TOGCNT100N_ADDR, v_t_100ns_pck);//100ns = nn cycles.
	MMC_Wr(UPCTL_TINIT_ADDR, v_t_init_us);  //200us.
	
//  MMC_Wr(UPCTL_TRSTH_ADDR, 2);      // 0 for ddr2; 500 for ddr3. 2 for simulation.
	MMC_Wr(UPCTL_TRSTH_ADDR, v_t_rsth_us);  // 0 for ddr2;  2 for simulation; 500 for ddr3. //???
	MMC_Wr(UPCTL_TRSTL_ADDR, v_t_rstl_us);  //?????
	
	MMC_Wr(UPCTL_MCFG_ADDR,v_mcfg);
	
	MMC_Wr(UPCTL_DFIODTCFG_ADDR, v_dfiodrcfg_adr);//add for Eric fine-tune
	
 
	//configure DDR PHY PUBL registers.
	//  2:0   011: DDR3 mode.	 100:	LPDDR2 mode.
	//  3:    8 bank. 
	MMC_Wr(PUB_DCR_ADDR, 0x3 | (1 << 3));
	MMC_Wr(PUB_PGCR_ADDR, 0x01842e04); //PUB_PGCR_ADDR: c8001008

	MMC_Wr( PUB_MR0_ADDR,v_msr0);
	MMC_Wr( PUB_MR1_ADDR,v_msr1);
	MMC_Wr( PUB_MR2_ADDR,v_msr2);
	MMC_Wr( PUB_MR3_ADDR,v_msr3);	
//	MMC_Wr( PUB_MR3_ADDR,0);	
	
	MMC_Wr(PUB_DTPR0_ADDR,v_pub_dtpr0);
	MMC_Wr(PUB_DTPR1_ADDR,v_pub_dtpr1);
	MMC_Wr(PUB_DTPR2_ADDR,v_pub_dtpr2);
	MMC_Wr(PUB_PTR0_ADDR,v_pub_ptr0);

	
//	MMC_Wr( PUB_PIR_ADDR, 0x17);//Add By Dai
	
	  __udelay(50);
	//wait PHY DLL LOCK
	while(!(MMC_Rd( PUB_PGSR_ADDR) & 1)) {}
	dbg_out("d",2);

	// configure DDR3_rst pin.
	MMC_Wr( PUB_ACIOCR_ADDR, MMC_Rd( PUB_ACIOCR_ADDR) & 0xdfffffff );
	MMC_Wr( PUB_DSGCR_ADDR,	MMC_Rd(PUB_DSGCR_ADDR) & 0xffffffef); 

	//MMC_Wr( PUB_ZQ0CR1_ADDR, 0x18); //???????
	//MMC_Wr( PUB_ZQ0CR1_ADDR, 0x7b); //???????
#ifdef CONFIG_TURN_OFF_ODT
	if(v_zq0cr0 & (1<<28))
	    MMC_Wr( PUB_ZQ0CR0_ADDR, v_zq0cr0);
    else
        MMC_Wr( PUB_ZQ0CR1_ADDR, v_zq0cr1);

    if(v_cmdzq)
	    MMC_Wr( MMC_CMDZQ_CTRL,  v_cmdzq);
#else
		MMC_Wr( PUB_ZQ0CR1_ADDR, v_zq0cr1);
#endif
	//for simulation to reduce the init time.
//	MMC_Wr(PUB_PTR1_ADDR,v_pub_ptr1);
//	MMC_Wr(PUB_PTR2_ADDR,v_pub_ptr2);


//   MMC_Wr( PUB_PIR_ADDR, 0x9);//Add By Dai

   __udelay(20);
	//wait DDR3_ZQ_DONE: 
#ifndef CONFIG_TURN_OFF_ODT
	while( !(MMC_Rd( PUB_PGSR_ADDR) & (1<< 2))) {}
#endif
	
	dbg_out("d",3);
	// wait DDR3_PHY_INIT_WAIT : 
#ifndef CONFIG_TURN_OFF_ODT
	while (!(MMC_Rd(PUB_PGSR_ADDR) & 1 )) {}
#endif
		dbg_out("d",4);
	// Monitor DFI initialization status.
#ifndef CONFIG_TURN_OFF_ODT
	while(!(MMC_Rd(UPCTL_DFISTSTAT0_ADDR) & 1)) {} 
#endif
	dbg_out("d",5);

	MMC_Wr(UPCTL_POWCTL_ADDR, 1);
	while(!(MMC_Rd( UPCTL_POWSTAT_ADDR & 1) )) {}
	dbg_out("d",6);

	// initial upctl ddr timing.
	MMC_Wr(UPCTL_TREFI_ADDR, v_t_refi_100ns);  // 7800ns to one refresh command.
	// wr_reg UPCTL_TREFI_ADDR, 78

	MMC_Wr(UPCTL_TMRD_ADDR, v_t_mrd);
	//wr_reg UPCTL_TMRD_ADDR, 4

	MMC_Wr(UPCTL_TRFC_ADDR, v_t_rfc);	//64: 400Mhz.  86: 533Mhz. 
	// wr_reg UPCTL_TRFC_ADDR, 86

	MMC_Wr(UPCTL_TRP_ADDR, v_t_rp);	// 8 : 533Mhz.
	//wr_reg UPCTL_TRP_ADDR, 8

	MMC_Wr(UPCTL_TAL_ADDR,	v_t_al);
	//wr_reg UPCTL_TAL_ADDR, 0

//  MMC_Wr(UPCTL_TCWL_ADDR,  v_t_cl-1 + v_t_al);
  MMC_Wr(UPCTL_TCWL_ADDR,  v_t_cwl);
	//wr_reg UPCTL_TCWL_ADDR, 6

	MMC_Wr(UPCTL_TCL_ADDR, v_t_cl);	 //6: 400Mhz. 8 : 533Mhz.
	// wr_reg UPCTL_TCL_ADDR, 8

	MMC_Wr(UPCTL_TRAS_ADDR, v_t_ras); //16: 400Mhz. 20: 533Mhz.
	//  wr_reg UPCTL_TRAS_ADDR, 20 

	MMC_Wr(UPCTL_TRC_ADDR, v_t_rc);  //24 400Mhz. 28 : 533Mhz.
	//wr_reg UPCTL_TRC_ADDR, 28

	MMC_Wr(UPCTL_TRCD_ADDR, v_t_rcd);	//6: 400Mhz. 8: 533Mhz.
	// wr_reg UPCTL_TRCD_ADDR, 8

	MMC_Wr(UPCTL_TRRD_ADDR, v_t_rrd); //5: 400Mhz. 6: 533Mhz.
	//wr_reg UPCTL_TRRD_ADDR, 6

	MMC_Wr(UPCTL_TRTP_ADDR, v_t_rtp);
	// wr_reg UPCTL_TRTP_ADDR, 4

	MMC_Wr(UPCTL_TWR_ADDR, v_t_wr);
	// wr_reg UPCTL_TWR_ADDR, 8

	MMC_Wr(UPCTL_TWTR_ADDR, v_t_wtr);
	//wr_reg UPCTL_TWTR_ADDR, 4

	MMC_Wr(UPCTL_TEXSR_ADDR, v_t_exsr);
	//wr_reg UPCTL_TEXSR_ADDR, 200

	MMC_Wr(UPCTL_TXP_ADDR, v_t_xp);
	//wr_reg UPCTL_TXP_ADDR, 4

	MMC_Wr(UPCTL_TDQS_ADDR, v_t_dqs);
	// wr_reg UPCTL_TDQS_ADDR, 2

	MMC_Wr(UPCTL_TRTW_ADDR, v_t_trtw);
	//wr_reg UPCTL_TRTW_ADDR, 2

	//MMC_Wr(UPCTL_TCKSRE_ADDR, 5);
	MMC_Wr(UPCTL_TCKSRE_ADDR, v_t_cksre);
	//wr_reg UPCTL_TCKSRE_ADDR, 5 

	//MMC_Wr(UPCTL_TCKSRX_ADDR, 5);
	MMC_Wr(UPCTL_TCKSRX_ADDR, v_t_cksrx);
	//wr_reg UPCTL_TCKSRX_ADDR, 5 

	MMC_Wr(UPCTL_TMOD_ADDR, v_t_mod);
	//wr_reg UPCTL_TMOD_ADDR, 8

	//MMC_Wr(UPCTL_TCKE_ADDR, 4);
	MMC_Wr(UPCTL_TCKE_ADDR, v_t_cke);
	//wr_reg UPCTL_TCKE_ADDR, 4 

	MMC_Wr(UPCTL_TZQCS_ADDR, 64);
	//wr_reg UPCTL_TZQCS_ADDR , 64 

//	MMC_Wr(UPCTL_TZQCL_ADDR, v_t_zqcl);
	MMC_Wr(UPCTL_TZQCL_ADDR, 512);
	//wr_reg UPCTL_TZQCL_ADDR , 512 

	MMC_Wr(UPCTL_TXPDLL_ADDR, 10);
	// wr_reg UPCTL_TXPDLL_ADDR, 10  

	MMC_Wr(UPCTL_TZQCSI_ADDR, 1000);
	// wr_reg UPCTL_TZQCSI_ADDR, 1000  

	MMC_Wr(UPCTL_SCFG_ADDR, 0xf00);
	// wr_reg UPCTL_SCFG_ADDR, 0xf00 
	
//	MMC_Wr(UPCTL_LPDDR2ZQCFG_ADDR,v_odtcfg); //????
//	MMC_Wr(UPCTL_ZQCR_ADDR,v_zqcr); //?????
 	
 	MMC_Wr( UPCTL_SCTL_ADDR, 1);
	while (!( MMC_Rd(UPCTL_STAT_ADDR) & 1))  {
		MMC_Wr(UPCTL_SCTL_ADDR, 1);
	}
	dbg_out("d",7);
	//config the DFI interface.
	MMC_Wr( UPCTL_PPCFG_ADDR, (0xf0 << 1) );
	MMC_Wr( UPCTL_DFITCTRLDELAY_ADDR, 2 );
	MMC_Wr( UPCTL_DFITPHYWRDATA_ADDR,  0x1 );
	MMC_Wr( UPCTL_DFITPHYWRLAT_ADDR, v_t_cwl -1  );    //CWL -1
	MMC_Wr( UPCTL_DFITRDDATAEN_ADDR, v_t_cl - 2  );    //CL -2
	MMC_Wr( UPCTL_DFITPHYRDLAT_ADDR, 15 );
	MMC_Wr( UPCTL_DFITDRAMCLKDIS_ADDR, 2 );
	MMC_Wr( UPCTL_DFITDRAMCLKEN_ADDR, 2 );
	MMC_Wr( UPCTL_DFISTCFG0_ADDR, 0x4  );
	MMC_Wr( UPCTL_DFITCTRLUPDMIN_ADDR, 0x4000 );
	MMC_Wr( UPCTL_DFILPCFG0_ADDR, ( 1 | (7 << 4) | (1 << 8) | (10 << 12) | (12 <<16) | (1 <<24) | ( 7 << 28)));
 
	MMC_Wr( UPCTL_CMDTSTATEN_ADDR, 1);
	while (!(MMC_Rd(UPCTL_CMDTSTAT_ADDR) & 1 )) {}
	dbg_out("d",8);

	//MMC_Wr( PUB_DTAR_ADDR, (0x0 | (0 <<12) | (7 << 28))); //training address is 0x90001800 not safe
	//MMC_Wr( PUB_DTAR_ADDR, (0xFc0 | (0xFFFF <<12) | (7 << 28))); //let training address is 0x9fffff00;
	MMC_Wr(PUB_DTAR_ADDR,v_dtar);
	serial_put_hex(MMC_Rd(PUB_DTAR_ADDR),32);
	f_serial_puts(" PUB_DTAR_ADDR\n");
	//start trainning.
	// DDR PHY initialization 
#ifdef CONFIG_TURN_OFF_ODT
	if(v_zq0cr0 & (1<<28))
		MMC_Wr( PUB_PIR_ADDR, 0x1e1);
  else
		MMC_Wr( PUB_PIR_ADDR, 0x1e9);
	//MMC_Wr( PUB_PIR_ADDR, 0x69); //no training
#else
		MMC_Wr( PUB_PIR_ADDR, 0x1e9);
#endif
	//DDR3_SDRAM_INIT_WAIT : 
	while( !(MMC_Rd(PUB_PGSR_ADDR & 1))) {}
	dbg_out("d",9);
	
	if(MMC_Rd(PUB_PGSR_ADDR) & (3<<5)){
        f_serial_puts("PUB_PGSR=");
	    serial_put_hex(MMC_Rd(PUB_PGSR_ADDR),8);
	    f_serial_puts("\n");
#ifdef CONFIG_TURN_OFF_ODT
        MMC_Wr( PUB_PIR_ADDR, 0x1e1 | (1<<28));
#else
		MMC_Wr( PUB_PIR_ADDR, 0x1e9 | (1<<28));
#endif
        while( !(MMC_Rd(PUB_PGSR_ADDR & 1))) {}
        dbg_out("d",0x91);
        f_serial_puts("PUB_PGSR=");
	    serial_put_hex(MMC_Rd(PUB_PGSR_ADDR),8);
	    f_serial_puts("\n");
	}

	//check ZQ calibraration status.
	stat = MMC_Rd(PUB_ZQ0SR0_ADDR);
	serial_put_hex(stat,32);
	f_serial_puts(" PUB_ZQ0SR0\n");
	stat = MMC_Rd(PUB_ZQ0SR1_ADDR);
	serial_put_hex(stat,32);
	f_serial_puts(" PUB_ZQ0SR1\n");

	//check data training result.
	stat = MMC_Rd(PUB_DX0GSR0_ADDR);
	serial_put_hex(stat,32);
	f_serial_puts(" PUB_DX0GSR0\n");
	wait_uart_empty();
	stat = MMC_Rd(PUB_DX1GSR0_ADDR);
	serial_put_hex(stat,32);
	f_serial_puts(" PUB_DX1GSR0\n");
	wait_uart_empty();
	stat = MMC_Rd(PUB_DX2GSR0_ADDR);
	serial_put_hex(stat,32);
	f_serial_puts(" PUB_DX2GSR0\n");
	wait_uart_empty();
	stat = MMC_Rd(PUB_DX3GSR0_ADDR);
	serial_put_hex(stat,32);
	f_serial_puts(" PUB_DX3GSR0\n");
	wait_uart_empty();


 	MMC_Wr(UPCTL_SCTL_ADDR, 2); // init: 0, cfg: 1, go: 2, sleep: 3, wakeup: 4
	while ((MMC_Rd(UPCTL_STAT_ADDR) & 0x7 ) != 3 ) {}
	dbg_out("d",10);
	__udelay(200);

//	MMC_Wr(MMC_DDR_CTRL,v_mmc_ddr_ctrl);
//	MMC_Wr(MMC_PHY_CTRL,v_mmc_phy_ctrl);
//	MMC_Wr(UPCTL_PHYCR_ADDR, 2);
//	MMC_Wr(MMC_REQ_CTRL, 0xff );  //enable request in kreboot.s
  
//	udelay(50);	

//	MMC_Wr(UPCTL_IOCR_ADDR, v_iocr); //248
	//traning result
/*
	MMC_Wr(UPCTL_RDGR0_ADDR,v_rdgr0); 
	MMC_Wr(UPCTL_RSLR0_ADDR,v_rslr0); 

	MMC_Wr(PUB_DX0GSR0_ADDR,v_dx0gsr0); 
	MMC_Wr(PUB_DX0GSR1_ADDR,v_dx0gsr1); 
	MMC_Wr(PUB_DX0DQSTR_ADDR,v_dx0dqstr); 
	
	MMC_Wr(PUB_DX1GSR0_ADDR,v_dx1gsr0); 
	MMC_Wr(PUB_DX1GSR1_ADDR,v_dx1gsr1); 
	MMC_Wr(PUB_DX1DQSTR_ADDR,v_dx1dqstr); 

	MMC_Wr(PUB_DX2GSR0_ADDR,v_dx2gsr0); 
	MMC_Wr(PUB_DX2GSR1_ADDR,v_dx2gsr1); 
	MMC_Wr(PUB_DX2DQSTR_ADDR,v_dx2dqstr); 

	MMC_Wr(PUB_DX3GSR0_ADDR,v_dx3gsr0); 
	MMC_Wr(PUB_DX3GSR1_ADDR,v_dx3gsr1); 
	MMC_Wr(PUB_DX3DQSTR_ADDR,v_dx3dqstr); 

	MMC_Wr(PUB_DX4GSR0_ADDR,v_dx4gsr0); 
	MMC_Wr(PUB_DX4GSR1_ADDR,v_dx4gsr1); 
	MMC_Wr(PUB_DX4DQSTR_ADDR,v_dx4dqstr); 

	MMC_Wr(PUB_DX5GSR0_ADDR,v_dx5gsr0); 
	MMC_Wr(PUB_DX5GSR1_ADDR,v_dx5gsr1); 
	MMC_Wr(PUB_DX5DQSTR_ADDR,v_dx5dqstr); 

	MMC_Wr(PUB_DX6GSR0_ADDR,v_dx6gsr0); 
	MMC_Wr(PUB_DX6GSR1_ADDR,v_dx6gsr1); 
	MMC_Wr(PUB_DX6DQSTR_ADDR,v_dx6dqstr); 

	MMC_Wr(PUB_DX7GSR0_ADDR,v_dx7gsr0); 
	MMC_Wr(PUB_DX7GSR1_ADDR,v_dx7gsr1); 
	MMC_Wr(PUB_DX7DQSTR_ADDR,v_dx7dqstr); 

	MMC_Wr(PUB_DX8GSR0_ADDR,v_dx8gsr0); 
	MMC_Wr(PUB_DX8GSR1_ADDR,v_dx8gsr1); 
	MMC_Wr(PUB_DX8DQSTR_ADDR,v_dx8dqstr); 
*/
//	MMC_Wr(MMC_REQ_CTRL, 0xff ); Already enable request in kreboot.s
	
	return 0;
}
Esempio n. 4
0
void  proc_user_cmd( void )
{
  uint32    val;
  int       ix;
  char     *ptr;
  
  if( (ix = DBG_RECV( cmd_rx_ptr, U1_RX_BUFF_SIZE )) > 1 )
  {
    cmd_rx_ptr[ix] = '\0';
    dbg_out( "\r\n" );
    
    ptr = strtok( (char *)cmd_rx_ptr, separator );
    util_cvt_low_format_cmd( ptr );
    
    if( util_cmp_str2nd( ptr, "get" ) == 0 )
    {
      proc_user_cmd_get();
    }
    else if( util_cmp_str2nd( ptr, "set" ) == 0 )
    {
      proc_user_cmd_set();
    }
    else
    {
      dbg_wait();
      dbg_out( "  get ver[version]\r\n" );
      dbg_out( "  get wifi dhcp\r\n" );
      dbg_out( "  get wifi sip[srv_ip]\r\n" );
      dbg_out( "  get wifi auth\r\n" );
      dbg_out( "  get wifi port\r\n" );
      dbg_out( "  get wifi ssid\r\n" );
      dbg_out( "  get wifi sspw\r\n" );
      dbg_wait();
      dbg_out( "  get time\r\n" );
      dbg_out( "  get date\r\n" );
      dbg_out( "  get fan[temp]\r\n" );
      dbg_out( "  get batt\r\n" );
      dbg_out( "  get gw[gateway]\r\n" );
      dbg_out( "  get sns[sensor]\r\n" );
      dbg_out( "  get log\r\n" );
      
      dbg_wait();
      dbg_out( "\r\n" );
      dbg_out( "  set wifi bypass\r\n" );
      val = eep_wifi_info.ip_srv;
      dbg_out( "  set wifi sip[srv_ip] %d.%d.%d.%d\r\n",
                (byte)(val >> 24), (byte)(val >> 16),
                (byte)(val >>  8), (byte)(val >>  0) );
      dbg_out( "  set wifi auth %d\r\n", eep_wifi_info.auth );
      dbg_out( "  set wifi ssid %s\r\n", eep_wifi_info.ssid );
      dbg_out( "  set wifi sspw %s\r\n", eep_wifi_info.sspw );
      dbg_out( "  set eep init\r\n" );
      dbg_out( "  set eep write[save]\r\n" );
      dbg_out( "  set zb isp\r\n" );
      dbg_out( "  set zb reset[rst]\r\n" );
      dbg_wait();
      dbg_out( "  set gw[gateway] fac 20\r\n" );
      dbg_out( "  set gw[gateway] num YYMMFT\r\n" );
      dbg_out( "      YY:Year, MM:Month, F:Factory, T:Type\r\n" );
      dbg_out( "    F=10:KIST, 20:NineOne, 30:Cesco, 40:Viliv\r\n" );
      dbg_out( "    T=00:CDMA,    01:WiFi,  02:ZigBee\r\n" );
      dbg_out( "  set gw sns_time %d\r\n", eep_hw_info.sns_rd_ms );
      dbg_out( "  set date %d %d %d\r\n",
                clk_rtc.year, clk_rtc.mon, clk_rtc.day );
      dbg_out( "  set time %d %d %d\r\n",
                clk_rtc.h, clk_rtc.m, clk_rtc.s );
      dbg_out( "  set fan %d %d[0~1000]\r\n",
               eep_hw_info.fan1_min, eep_hw_info.fan2_min );
      dbg_out( "  set fan freq %d[1~72000]\r\n", eep_hw_info.fan_base_f );
      dbg_wait();
      dbg_out( "  set log only\r\n" );
      dbg_out( "  set log clr[rst]\r\n" );
      dbg_out( "  set log kist\r\n" );
      
      dbg_wait();
      dbg_out( "\r\n" );
      dbg_out( "  set wifi ssid %s\r\n", eep_wifi_info.ssid );
      dbg_out( "  set wifi sspw %s\r\n", eep_wifi_info.sspw );
      dbg_out( "  set wifi auth %d\r\n", eep_wifi_info.auth );
      dbg_out( "           auth [WEB=1][WPA=2]\r\n" );
      dbg_out( "  set wifi port %d\r\n", eep_wifi_info.port_srv );
      dbg_out( "  set eep write\r\n" );
      dbg_out( "  Power OFF --> ON\r\n" );
      dbg_wait();
    }
  }
Esempio n. 5
0
void disp_pctl(void)
{
#if 0
#if 0
	dbg_out("DDR_PLL_CNTL:",readl(P_HHI_DDR_PLL_CNTL));
	dbg_out("DDR_PLL_CNTL2:",readl(P_HHI_DDR_PLL_CNTL2));
	dbg_out("DDR_PLL_CNTL3:",readl(P_HHI_DDR_PLL_CNTL3));
	dbg_out("DDR_PLL_CNTL4:", readl(P_HHI_DDR_PLL_CNTL4));
	
	dbg_out("MC_DDR_CTRL:",readl(P_MMC_DDR_CTRL));
	dbg_out("MMC_PHY_CTRL:",readl(P_MMC_PHY_CTRL));
	dbg_out("MMC_CLK_CNTL:",MMC_Rd(MMC_CLK_CNTL));
		
 	 dbg_out("U_TOGCNT1U_ADDR ",MMC_Rd(UPCTL_TOGCNT1U_ADDR )); 
 	 dbg_out("U_TOGCNT100N_ADDR ",MMC_Rd(UPCTL_TOGCNT100N_ADDR ));
 	 dbg_out("U_TINIT_ADDR ",MMC_Rd(UPCTL_TINIT_ADDR )); 
 	 dbg_out("U_TREFI:",MMC_Rd(UPCTL_TREFI_ADDR )); 
 
   dbg_out("U_TMRD:",MMC_Rd(UPCTL_TMRD_ADDR )); 
 	 dbg_out("U_TRFC:",MMC_Rd(UPCTL_TRFC_ADDR )); 
 	 dbg_out("U_TRP:",MMC_Rd(UPCTL_TRP_ADDR )); 
 	 dbg_out("U_TAL:",MMC_Rd(UPCTL_TAL_ADDR )); 
 	 dbg_out("U_TCL:",MMC_Rd(UPCTL_TCL_ADDR )); 
 	 dbg_out("U_TRAS:",MMC_Rd(UPCTL_TRAS_ADDR )); 
 	 dbg_out("U_TRC:",MMC_Rd(UPCTL_TRC_ADDR )); 
 	 dbg_out("U_TRCD:",MMC_Rd(UPCTL_TRCD_ADDR )); 
 	 dbg_out("U_TRRD:",MMC_Rd(UPCTL_TRRD_ADDR ));
 	 dbg_out("U_TRTP:",MMC_Rd(UPCTL_TRTP_ADDR ));
 	 dbg_out("U_TWR:",MMC_Rd(UPCTL_TWR_ADDR ));
 	 dbg_out("U_TWTR:",MMC_Rd(UPCTL_TWTR_ADDR )); 
 	 dbg_out("U_TEXSR:",MMC_Rd(UPCTL_TEXSR_ADDR )); 
 	 dbg_out("U_TXP:",MMC_Rd(UPCTL_TXP_ADDR ));
 	 dbg_out("U_TDQS:",MMC_Rd(UPCTL_TDQS_ADDR ));
 	 dbg_out("U_TRTW:",MMC_Rd(UPCTL_TRTW_ADDR ));
 	 dbg_out("U_TMOD:",MMC_Rd(UPCTL_TMOD_ADDR ));
 	 dbg_out("U_TCWL:",MMC_Rd(UPCTL_TCWL_ADDR ));
	
	
		dbg_out("U_MCFG:",MMC_Rd(UPCTL_MCFG_ADDR));
		dbg_out("U_TZQCL:",MMC_Rd(UPCTL_TZQCL_ADDR));
		
		dbg_out("U_TRSTH:",MMC_Rd(UPCTL_TRSTH_ADDR));
		dbg_out("U_TRSTL:",MMC_Rd(UPCTL_TRSTL_ADDR));
		dbg_out("U_TCKE:",MMC_Rd(UPCTL_TCKE_ADDR));
		dbg_out("U_TCKSRE:",MMC_Rd(UPCTL_TCKSRE_ADDR));
		dbg_out("U_TCKSRX:",MMC_Rd(UPCTL_TCKSRX_ADDR));
		
		dbg_out("PUB_DTPR0:",MMC_Rd(PUB_DTPR0_ADDR));
		dbg_out("PUB_DTPR1:",MMC_Rd(PUB_DTPR1_ADDR));
		dbg_out("PUB_DTPR2:",MMC_Rd(PUB_DTPR2_ADDR));
		dbg_out("PUB_PTR0:",MMC_Rd(PUB_PTR0_ADDR));
		dbg_out("PUB_PTR1:",MMC_Rd(PUB_PTR1_ADDR));
		dbg_out("PUB_PTR2:",MMC_Rd(PUB_PTR2_ADDR));
		
		dbg_out("PUB_MR0:",MMC_Rd( PUB_MR0_ADDR));
		dbg_out("PUB_MR1:",MMC_Rd( PUB_MR1_ADDR));
		dbg_out("PUB_MR2:",MMC_Rd( PUB_MR2_ADDR));
		dbg_out("PUB_MR3:",MMC_Rd( PUB_MR3_ADDR));	

    dbg_out("U_PPCFG:",MMC_Rd( UPCTL_PPCFG_ADDR));
    dbg_out("U_DFISTCFG0:",MMC_Rd( UPCTL_DFISTCFG0_ADDR));
    dbg_out("U_DFITPHYWRLAT:",MMC_Rd( UPCTL_DFITPHYWRLAT_ADDR));
    dbg_out("U_DFITRDDATAEN:",MMC_Rd( UPCTL_DFITRDDATAEN_ADDR));
    dbg_out("U_DFITPHYWRDATA:",MMC_Rd( UPCTL_DFITPHYWRDATA_ADDR));
    dbg_out("U_DFITPHYRDLAT:",MMC_Rd( UPCTL_DFITPHYRDLAT_ADDR));
    dbg_out("U_DFITDRAMCLKDIS:",MMC_Rd( UPCTL_DFITDRAMCLKDIS_ADDR));
    dbg_out("U_DFITDRAMCLKEN:",MMC_Rd( UPCTL_DFITDRAMCLKEN_ADDR));
    dbg_out("U_DFITCTRLDELAY:",MMC_Rd( UPCTL_DFITCTRLDELAY_ADDR));
    dbg_out("U_DFITCTRLUPDMIN:",MMC_Rd( UPCTL_DFITCTRLUPDMIN_ADDR));
    dbg_out("U_DFILPCFG0:",MMC_Rd( UPCTL_DFILPCFG0_ADDR)); 
    dbg_out("PUB_PIR:",MMC_Rd( PUB_PIR_ADDR)); 
    dbg_out("PUB_PGCR:",MMC_Rd( PUB_PGCR_ADDR)); 
	
		dbg_out("U_LPDDR2ZQCFG:",MMC_Rd(UPCTL_LPDDR2ZQCFG_ADDR));
	  dbg_out("U_ZQCR:",MMC_Rd(UPCTL_ZQCR_ADDR));
	  
	  
	  
	dbg_out("PUB_ACIOCR:",MMC_Rd( PUB_ACIOCR_ADDR));
	dbg_out("PUB_DSGCR:",MMC_Rd( PUB_DSGCR_ADDR)); 

  dbg_out("PUB_ZQ0CR1:",MMC_Rd( PUB_ZQ0CR1_ADDR));
    
	dbg_out("U_TZQCS:",MMC_Rd(UPCTL_TZQCS_ADDR));
	dbg_out("U_TZQCL:",MMC_Rd(UPCTL_TZQCL_ADDR));

	dbg_out("U_TXPDLL:",MMC_Rd(UPCTL_TXPDLL_ADDR));

	dbg_out("U_TZQCSI:",MMC_Rd(UPCTL_TZQCSI_ADDR));

	dbg_out("U_SCFG:",MMC_Rd(UPCTL_SCFG_ADDR));
	dbg_out("PUB_DTAR:",MMC_Rd( PUB_DTAR_ADDR)); 

	dbg_out("MMC_REQ_CTRL:",MMC_Rd(MMC_REQ_CTRL)); 
	
	dbg_out("U_DLLCR9:",MMC_Rd(UPCTL_DLLCR9_ADDR)); //2a8	
	dbg_out("U_IOCR:",MMC_Rd(UPCTL_IOCR_ADDR)); //248
#endif
	
  dbg_out("U_DLLCR0:",MMC_Rd(UPCTL_DLLCR0_ADDR)); //284
  dbg_out("U_DLLCR1:",MMC_Rd(UPCTL_DLLCR1_ADDR)); //288
  dbg_out("U_DLLCR2:",MMC_Rd(UPCTL_DLLCR2_ADDR)); //28c
  dbg_out("U_DLLCR3:",MMC_Rd(UPCTL_DLLCR3_ADDR)); //290
  dbg_out("U_DQSTR:",MMC_Rd(UPCTL_DQSTR_ADDR));   //2e4
  dbg_out("U_DQSNTR:",MMC_Rd(UPCTL_DQSNTR_ADDR)); //2e8
  dbg_out("U_DQTR0:",MMC_Rd(UPCTL_DQTR0_ADDR));     //2c0
  dbg_out("U_DQTR1:",MMC_Rd(UPCTL_DQTR1_ADDR));     //2c4
  dbg_out("U_DQTR2:",MMC_Rd(UPCTL_DQTR2_ADDR));     //2c8
  dbg_out("U_DQTR3:",MMC_Rd(UPCTL_DQTR3_ADDR));     //2cc

	 dbg_out("U_RDGR0_ADDR      ",MMC_Rd(UPCTL_RDGR0_ADDR));
	 dbg_out("U_RSLR0_ADDR     ",MMC_Rd(UPCTL_RSLR0_ADDR));


  dbg_out("PUB_DX0GSR0:", MMC_Rd(PUB_DX0GSR0_ADDR)); 
	dbg_out("PUB_DX0GSR1:", MMC_Rd(PUB_DX0GSR1_ADDR)); 
	dbg_out("PUB_DX0DQSTR:",MMC_Rd(PUB_DX0DQSTR_ADDR)); 

  dbg_out("PUB_DX1GSR0:", MMC_Rd(PUB_DX1GSR0_ADDR)); 
	dbg_out("PUB_DX1GSR1:", MMC_Rd(PUB_DX1GSR1_ADDR)); 
	dbg_out("PUB_DX1DQSTR:",MMC_Rd(PUB_DX1DQSTR_ADDR)); 

  dbg_out("PUB_DX2GSR0:", MMC_Rd(PUB_DX2GSR0_ADDR)); 
	dbg_out("PUB_DX2GSR1:", MMC_Rd(PUB_DX2GSR1_ADDR)); 
	dbg_out("PUB_DX2DQSTR:",MMC_Rd(PUB_DX2DQSTR_ADDR)); 

  dbg_out("PUB_DX3GSR0:", MMC_Rd(PUB_DX3GSR0_ADDR)); 
	dbg_out("PUB_DX3GSR1:", MMC_Rd(PUB_DX3GSR1_ADDR)); 
	dbg_out("PUB_DX3DQSTR:",MMC_Rd(PUB_DX3DQSTR_ADDR)); 

  dbg_out("PUB_DX4GSR0:", MMC_Rd(PUB_DX4GSR0_ADDR)); 
	dbg_out("PUB_DX4GSR1:", MMC_Rd(PUB_DX4GSR1_ADDR)); 
	dbg_out("PUB_DX4DQSTR:",MMC_Rd(PUB_DX4DQSTR_ADDR)); 

  dbg_out("PUB_DX5GSR0:", MMC_Rd(PUB_DX5GSR0_ADDR)); 
	dbg_out("PUB_DX5GSR1:", MMC_Rd(PUB_DX5GSR1_ADDR)); 
	dbg_out("PUB_DX5DQSTR:",MMC_Rd(PUB_DX5DQSTR_ADDR)); 

  dbg_out("PUB_DX6GSR0:", MMC_Rd(PUB_DX6GSR0_ADDR)); 
	dbg_out("PUB_DX6GSR1:", MMC_Rd(PUB_DX6GSR1_ADDR)); 
	dbg_out("PUB_DX6DQSTR:",MMC_Rd(PUB_DX6DQSTR_ADDR)); 

  dbg_out("PUB_DX7GSR0:", MMC_Rd(PUB_DX7GSR0_ADDR)); 
	dbg_out("PUB_DX7GSR1:", MMC_Rd(PUB_DX7GSR1_ADDR)); 
	dbg_out("PUB_DX7DQSTR:",MMC_Rd(PUB_DX7DQSTR_ADDR)); 

  dbg_out("PUB_DX8GSR0:", MMC_Rd(PUB_DX8GSR0_ADDR)); 
	dbg_out("PUB_DX8GSR1:", MMC_Rd(PUB_DX8GSR1_ADDR)); 
	dbg_out("PUB_DX8DQSTR:",MMC_Rd(PUB_DX8DQSTR_ADDR)); 

#endif
}
Esempio n. 6
0
 inline void dbg_out(const std::string& s)
 {
   dbg_out(utils::string_to_wstring(s));
 }
Esempio n. 7
0
GtkWidget *
internal_create_fuzai_editor(void){
  GtkWidget *window;
  GtkWidget *titleView;
  GtkWidget *entry;
  GtkWidget *text_view;
  int max_index;
  int max_message;
  int index;
  int rc;
  gchar *title;
  gchar *message;
  GtkTreeModel *model;
  GtkTreeIter   newrow;
  GtkTreeSelection   *sel;
  GtkTextBuffer *buffer;
  gint width,height;

  rc=hostinfo_refer_absent_length(&max_index);
  if (rc<0)
    goto error_out;
  rc=hostinfo_refer_absent_message_slots(&max_message);
  if (rc<0)
    goto error_out;

  if (max_index>max_message)
    max_index=max_message;

  window=create_absenceEditor();
  g_assert(window);
  titleView=GTK_WIDGET(lookup_widget(window,"absenseTitles"));
  g_assert(titleView);
  entry=GTK_WIDGET(lookup_widget(window,"AbsenceTitleEntry"));
  g_assert(entry);
  text_view=GTK_WIDGET(lookup_widget(window,"fuzaiText"));
  g_assert(text_view);

  setup_fuzai_view(GTK_TREE_VIEW(titleView));
  for(index=0;index<max_index;++index) {
    hostinfo_get_absent_title(index,(const char **)&title);

    model = gtk_tree_view_get_model(GTK_TREE_VIEW(titleView));
      
    gtk_list_store_append(GTK_LIST_STORE(model), &newrow);
      
    gtk_list_store_set(GTK_LIST_STORE(model), &newrow, 
		       0, title,
		       1, index,
		       -1);
    g_free(title);
  }
  sel=gtk_tree_view_get_selection(GTK_TREE_VIEW(titleView));
  gtk_tree_model_get_iter_first(model, &newrow);
  gtk_tree_selection_select_iter (sel, &newrow);

  hostinfo_get_absent_title(0,(const char **)&title);
  gtk_entry_set_text(GTK_ENTRY(entry), title); 
  g_free(title);

  hostinfo_get_absent_message(0, &message);
  buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
  gtk_text_buffer_set_text(buffer,message,-1);
  g_free(message);

  if (!hostinfo_get_ipmsg_attach_editor_size(&width,&height)){
    dbg_out("Resize:(%d,%d)\n",width,height);
    gtk_window_resize (GTK_WINDOW(window),width,height);
  }


  return window;
 error_out:
  return NULL;
}
Esempio n. 8
0
void
update_user_entry(GList *top,GtkWidget *view,gboolean is_forced) {
  GtkTreeIter              toplevel;
  GtkListStore           *liststore = NULL;
  GtkWidget             *usersEntry = NULL;
  GtkTreeViewColumn            *col = NULL;
  userdb_t            *current_user = NULL;
  int                             i = 0;
  int                   users_count = 0;
  int                          prio = 0;
  guint                       state = 0;
  int                            id = 0;
  gchar              *nick_name_ref = NULL;
  gchar                     num_str[32];

  if ( (!top) || (!view) )
    return;

  state=hostinfo_refer_header_state();

  release_user_entry(GTK_TREE_VIEW(view));
  liststore = gtk_list_store_new(MAX_VIEW_ID,
                                 G_TYPE_STRING,
                                 G_TYPE_STRING,
                                 G_TYPE_STRING,
                                 G_TYPE_STRING,
                                 G_TYPE_STRING,
				 G_TYPE_STRING);

  for(i=0;(current_user=g_list_nth_data(top,i));++i) {
    g_assert(current_user);

    nick_name_ref = current_user->nickname;
    if ( (current_user->nickname == NULL) || ( current_user->nickname[0] == '\0' ) ) {
      if ( (current_user->user != NULL) && (current_user->user[0] != '\0') )
	nick_name_ref = current_user->user;
      else
	nick_name_ref = _("Unknown");
    }

    dbg_out("Update\n");
    dbg_out("NickName: %s\n", current_user->nickname);
    dbg_out("Group: %s\n",current_user->group);
    dbg_out("User: %s\n",current_user->user);
    dbg_out("Host: %s\n",current_user->host);
    dbg_out("IP Addr: %s\n",current_user->ipaddr);
    dbg_out("Priority: %d\n",current_user->prio);

    prio=current_user->prio;
    memset(num_str,0,32);
    if (prio>0)
      snprintf(num_str,31,"%d",prio);
    else
      snprintf(num_str,31,"-");
    num_str[31]='\0';

    if ( (prio>=0) || (is_forced) ){
      /* Append a top level row and leave it empty */
      gtk_list_store_append(liststore, &toplevel);
      gtk_list_store_set(liststore, &toplevel,
			 USER_VIEW_NICKNAME_ID, nick_name_ref,
			 USER_VIEW_GROUP_ID,current_user->group,
			 USER_VIEW_HOST_ID,current_user->host,
			 USER_VIEW_IPADDR_ID,current_user->ipaddr,
			 USER_VIEW_LOGON_ID,current_user->user,
			 USER_VIEW_PRIO_ID,num_str,
			 -1);
    }
    ++users_count;
    fflush(stdout);
  }
  gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(liststore));

  g_object_unref(liststore); /* destroy model automatically with view */

  gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)),
                             GTK_SELECTION_MULTIPLE );
  /*
   * ユーザ数更新
   */
  usersEntry=lookup_widget(GTK_WIDGET(view),"messageWinUsersEntry");
  g_assert(usersEntry);
  snprintf(num_str,31,"%d",users_count);
  gtk_entry_set_text(GTK_ENTRY(usersEntry), num_str);

#if GTK_CHECK_VERSION(2,10,0)
  gtk_tree_view_set_rubber_banding (GTK_TREE_VIEW(view),TRUE);
  if (GTK_WIDGET_REALIZED(view)) {
#if GTK_CHECK_VERSION(2,10,6)
    gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(view),TRUE);
    if (state & HEADER_VISUAL_GRID_ID)
      gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(view),GTK_TREE_VIEW_GRID_LINES_BOTH);
#endif
  }
#endif

  return;
}
Esempio n. 9
0
void
setup_message_tree_view(GtkWidget *view) {
  GtkTreeViewColumn   *col;
  GtkCellRenderer     *renderer;
  guint state;
  GList *cols,*node;
  GtkTreeViewColumn  *view_cols[MAX_VIEW_ID];
  int col_id;
  int i;

  state=hostinfo_refer_header_state();
  /*
   * タイトル設定   
   */
  /* --- Column #1 --- */
  col=create_user_view_column(USER_VIEW_NICKNAME_ID, _("User"), G_CALLBACK(on_messageUserTree_user_clicked));
  view_cols[USER_VIEW_NICKNAME_ID]=col;
  g_assert(GET_ID(col)==USER_VIEW_NICKNAME_ID);
  
  /* --- Column #2 --- */
  col=create_user_view_column(USER_VIEW_GROUP_ID, _("Group"), G_CALLBACK(on_messageUserTree_group_clicked));
  view_cols[USER_VIEW_GROUP_ID]=col;
  g_assert(GET_ID(col)==USER_VIEW_GROUP_ID);
  if (state & HEADER_VISUAL_GROUP_ID)
    gtk_tree_view_column_set_visible(col,TRUE);
  else
    gtk_tree_view_column_set_visible(col,FALSE);

  /* --- Column #3 --- */
  col=create_user_view_column(USER_VIEW_HOST_ID, _("Host"), G_CALLBACK(on_messageUserTree_host_clicked));
  view_cols[USER_VIEW_HOST_ID]=col;
  g_assert(GET_ID(col)==USER_VIEW_HOST_ID);
  if (state & HEADER_VISUAL_HOST_ID)
    gtk_tree_view_column_set_visible(col,TRUE);
  else
    gtk_tree_view_column_set_visible(col,FALSE);

  /* --- Column #4 --- */
  col=create_user_view_column(USER_VIEW_IPADDR_ID, _("IP Address"), G_CALLBACK(on_messageUserTree_ipaddr_clicked));
  view_cols[USER_VIEW_IPADDR_ID]=col;
  g_assert(GET_ID(col)==USER_VIEW_IPADDR_ID);
  if (state & HEADER_VISUAL_IPADDR_ID)
    gtk_tree_view_column_set_visible(col,TRUE);
  else
    gtk_tree_view_column_set_visible(col,FALSE);

  /* --- Column #5 --- */
  col=create_user_view_column(USER_VIEW_LOGON_ID, _("LogOn"), G_CALLBACK(on_messageUserTree_logon_clicked));
  view_cols[USER_VIEW_LOGON_ID]=col;
  g_assert(GET_ID(col)==USER_VIEW_LOGON_ID);
  if (state & HEADER_VISUAL_LOGON_ID)
    gtk_tree_view_column_set_visible(col,TRUE);
  else
    gtk_tree_view_column_set_visible(col,FALSE);

  /* --- Column #6 --- */
  col=create_user_view_column(USER_VIEW_PRIO_ID, _("Priority"), G_CALLBACK(on_messageUserTree_priority_clicked));
  view_cols[USER_VIEW_PRIO_ID]=col;
  g_assert(GET_ID(col)==USER_VIEW_PRIO_ID);
  if (state & HEADER_VISUAL_PRIO_ID)
    gtk_tree_view_column_set_visible(col,TRUE);
  else
    gtk_tree_view_column_set_visible(col,FALSE);

  /* Append all columns  */
  for(i=0;i<MAX_VIEW_ID;++i) {
    if (!hostinfo_get_header_order(i,&col_id)) {
      dbg_out("append:%d->%d\n",i,col_id);
      gtk_tree_view_append_column(GTK_TREE_VIEW(view), view_cols[col_id]);
    }
  }

  gtk_signal_connect (GTK_OBJECT (view), "button_press_event",
		      GTK_SIGNAL_FUNC (on_message_view_event_button_press_event),
		      NULL);

}