コード例 #1
0
int
opal_timer_linux_open(void)
{
    FILE *fp;
    char *loc;
    float cpu_f;
    int ret;
    char buf[1024];

    fp = fopen("/proc/cpuinfo", "r");
    if (NULL == fp) {
        return OPAL_ERR_IN_ERRNO;
    }

    opal_timer_linux_freq = 0;

    if (0 == opal_timer_linux_freq) {
        /* first, look for a timebase field.  probably only on PPC,
           but one never knows */
        loc = find_info(fp, "timebase", buf, 1024);
        if (NULL != loc) {
            int freq;
            ret = sscanf(loc, "%d", &freq);
            if (1 == ret) {
                opal_timer_linux_freq = freq;
            }
        }
    }

    if (0 == opal_timer_linux_freq) {
        /* find the CPU speed - most timers are 1:1 with CPU speed */
        loc = find_info(fp, "cpu MHz", buf, 1024);
        if (NULL != loc) {
            ret = sscanf(loc, "%f", &cpu_f);
            if (1 == ret) {
                /* numer is in MHz - convert to Hz and make an integer */
                opal_timer_linux_freq = (opal_timer_t) cpu_f * 1000000;
            }
        }
    }

    if (0 == opal_timer_linux_freq) {
        /* look for the sparc way of getting cpu frequency */
        loc = find_info(fp, "Cpu0ClkTck", buf, 1024);
        if (NULL != loc) {
            unsigned int freq;
            ret = sscanf(loc, "%x", &freq);
            if (1 == ret) {
                opal_timer_linux_freq = freq;
            }
        }
    }

    fclose(fp);

    return OPAL_SUCCESS;
}
コード例 #2
0
ファイル: testshow.cpp プロジェクト: marxsu/IFMA
//int MYCall_Back(void *pdata,int argc,char *value[],char *name[]);
TestShow::TestShow(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::TestShow)
{
    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint);

    page = -1;
    //初始化显示框
    model=new QStandardItemModel(this);
    model->setColumnCount(1);//ID option name age gender  Result time,add some ,totally 11
    ui->lineEdit_Year->setValidator(new QIntValidator(0,10000,this));
    ui->lineEdit_Month->setValidator(new QIntValidator(0,12,this));
    ui->lineEdit_Day->setValidator(new QIntValidator(0,30,this));
    ui->pushButton_Exit->setFocusPolicy(Qt::NoFocus);
    connect(ui->pushButton_up,SIGNAL(clicked()),this,SLOT(page_up()));
    connect(ui->pushButton_down,SIGNAL(clicked()),this,SLOT(page_down()));
    connect(ui->pushButton_go,SIGNAL(clicked()),this,SLOT(page_go()));
    connect(ui->pushButton_Exit,SIGNAL(clicked()),this,SLOT(home()));
    connect(ui->tableView,SIGNAL(clicked(QModelIndex)),this,SLOT(setPrintTrue(QModelIndex)));
    connect(ui->pushButton_print,SIGNAL(clicked()),this,SLOT(PrintItem()));
    connect(ui->pushButton_Search,SIGNAL(clicked()),this,SLOT(find_info()));
    connect(ui->pushButton_LogOut,SIGNAL(clicked()),this,SLOT(logout()));
    connect(ui->pushButton_Edit,SIGNAL(clicked()),this,SLOT(view_clicked()));
    QRegExp rx("^[0-9]{1,10}$");//这个10就是最大长度
    QValidator *validator = new QRegExpValidator(rx,0);
    ui->lineEdit_Page->setValidator(validator);
    dateEdit=new QDateEdit(this);
    dateEdit->setDisplayFormat("yyyy-MM-dd");
    dateEdit->setGeometry(QRect(413,90,163,29));
    dateEdit->setAlignment(Qt::AlignCenter);
    dateEdit->setDate(QDateTime::currentDateTime().date());

    ui->pushButton->setVisible(false);
}
コード例 #3
0
ファイル: dummy-ups.c プロジェクト: sbutler/nut
static int setvar(const char *varname, const char *val)
{
	dummy_info_t *item;

	upsdebugx(2, "entering setvar(%s, %s)", varname, val);

	/* FIXME: the below is only valid if (mode == MODE_DUMMY)
	 * if (mode == MODE_REPEATER) => forward
	 * if (mode == MODE_META) => ?
	 */
	if (!strncmp(varname, "ups.status", 10))
	{
		status_init();
		 /* FIXME: split and check values (support multiple values), à la usbhid-ups */
		status_set(val);
		status_commit();

		return STAT_SET_HANDLED;
	}

	/* Check variable validity */
	if (!is_valid_data(varname))
	{
		upsdebugx(2, "setvar: invalid variable name (%s)", varname);
		return STAT_SET_UNKNOWN;
	}

	/* Check value validity */
	if (!is_valid_value(varname, val))
	{
		upsdebugx(2, "setvar: invalid value (%s) for variable (%s)", val, varname);
		return STAT_SET_UNKNOWN;
	}

	/* If value is empty, remove the variable (FIXME: do we need
	 * a magic word?) */
	if (strlen(val) == 0)
	{
		dstate_delinfo(varname);
	}
	else
	{
		dstate_setinfo(varname, "%s", val);

		if ( (item = find_info(varname)) != NULL)
		{
			dstate_setflags(item->info_type, item->info_flags);

			/* Set max length for strings, if needed */
			if (item->info_flags & ST_FLAG_STRING)
				dstate_setaux(item->info_type, item->info_len);
		}
	}
	return STAT_SET_HANDLED;
}
コード例 #4
0
/*
*********************************************************************************************************
*                           mem_set_voltage
*
*Description: set voltage for mem;
*
*Arguments  : type      voltage type, defined as "enum power_vol_type_e";
*             voltage   voltage value, based on "mv";
*
*Return     : 0: succeed;
*			-1: failed.
*Notes      :
*
*********************************************************************************************************
*/
__s32  mem_set_voltage(enum power_vol_type_e type, __s32 voltage)
{
	struct axp_info *info = 0;
	__u8 val, mask, reg_val;
	__s32 ret = 0;

	info = find_info(type);
	if (info == 0) {
		return -1;
	}

	if (check_range(info, voltage)) {
		return -1;
	}

	if (type != POWER_VOL_LDO4)
		val = raw_lib_udiv((voltage-info->min_uV+info->step_uV-1), info->step_uV);
	else{
		if(voltage == 1250000 ){
			val = 0;
		}
		else{
			val = raw_lib_udiv((voltage-1200000+info->step_uV-1), info->step_uV);
			if(val > 16){
				val = val - 6;
			}
			else if(val > 13){
				val = val - 5;
			}
			else if(val > 12){
				val = val - 4;
			}
			else if(val > 8)
				val = 8;
		}
	}


	val <<= info->vol_shift;
	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;

	if( 0 != twi_byte_rw(TWI_OP_RD,AXP_ADDR,info->vol_reg, &reg_val)){
		return -1;
	}

	if ((reg_val & mask) != val) {
		reg_val = (reg_val & ~mask) | val;
		if(0 != twi_byte_rw(TWI_OP_WR,AXP_ADDR,info->vol_reg, &reg_val)){
			return -1;
		}
	}

	return ret;
}
コード例 #5
0
ファイル: inode.c プロジェクト: taysom/tau
info_s *get_info (u64 ino)
{
    info_s	*info;
    FN;
    PRd(ino);
    info = find_info(ino);
    if (info) return info;

    info = find_inode(ino);
    if (!info) return NULL;

    add_info(ino, info);
    return info;
}
コード例 #6
0
ファイル: sasl.c プロジェクト: ArchUser/hexchat
static sasl_info*
get_info (void)
{
	const char* name;
	name = hexchat_get_info (ph, "network");

	if (name)
	{
		return find_info (name);
	}
	else
	{
		return NULL;
	}
}
コード例 #7
0
ファイル: dummy-ups.c プロジェクト: sbutler/nut
/* check if data exists in our data table */
static int is_valid_data(const char* varname)
{
	dummy_info_t *item;

	if ( (item = find_info(varname)) != NULL)
	{
		return 1;
	}

	/* FIXME: we need to have the full data set before
	 * enforcing controls! We also need a way to automate
	 * the update / sync process (with cmdvartab?!) */

	upsdebugx(1, "Unknown data. Committing anyway...");
	return 1;
	/* return 0;*/
}
コード例 #8
0
ファイル: standby_power.c プロジェクト: pocketbook/U7
/*
*********************************************************************************************************
*                           standby_get_voltage
*
*Description: get voltage for standby;
*
*Arguments  : type  voltage type, defined as "enum power_vol_type_e";
*
*Return     : voltage value, based on "mv";
*
*Notes      :
*
*********************************************************************************************************
*/
__u32 standby_get_voltage(enum power_vol_type_e type)
{
    struct axp_info *info = 0;
    __u8 val, mask;

    info = find_info(type);
    if (info == 0) {
        return -1;
    }

    twi_byte_rw(TWI_OP_RD,AXP_ADDR,info->vol_reg, &val);

    mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
    val = (val & mask) >> info->vol_shift;
    if (type != POWER_VOL_LDO4)
        return info->min_uV + info->step_uV * val;
    else
        return axp20_ldo4_data[val]*1000;
}
コード例 #9
0
ファイル: hd.c プロジェクト: jamjr/Helios-NG
/*
 * Given a Helios device name, set this up as a major device unit
 * (one of the MAX_HELIOS_DEVICES) and start a driver routine for it.
 * Returns pointer to error message on failure.  NULL otherwise.
 */
char *hd_start(char *devname, int major)
{
	static char buffer[100];
	void *devinfo;
	InfoNode *deviceinfo;
	DiscDevInfo *ddi;

	/* The major device number */
	if ((major < 0) || (major >= MAX_HELIOS_DEVICES) || (hd[major].dcb)) {
		return("Invalid major device or device already in use");
	}

	/* Get devinfo */
	if ((devinfo = load_devinfo()) == NULL)
		return("Failed to load devinfo file");

	/* Is entry there ? */
	if ((deviceinfo = find_info(devinfo,Info_DiscDev,devname)) == NULL) {
		Free(devinfo);
		return("No entry for device in devinfo");
	}
	ddi = (DiscDevInfo *)RTOA(deviceinfo->Info);

	/* Open it ! */
	if ((hd[major].dcb = OpenDevice(RTOA(ddi->Name),ddi))
	    == NULL) {
		strcpy(buffer,"Failed to open device ");
		strcat(buffer,RTOA(ddi->Name));
		Free(devinfo);
		return(buffer);
	}
	Free(devinfo);

	/* Fork off the device server */
	if (!Fork(5000,hd_intr_server,sizeof(int),major)) {
		return("Failed to start device server");
	}

	/* No errors */
	return(NULL);
}
コード例 #10
0
ファイル: help.c プロジェクト: papoanaya/oleo
void
builtin_help (char * name)
{
  char info_name[100];
  struct info_buffer * ib;

  if (strlen (name) > sizeof (info_name) - 20)
    io_error_msg ("No built in help for %s.", name);

  sprintf (info_name, "_info_%s", name);
  ib = find_info (info_name);

  if (!ib)
    {
      char ** msg = forminfo_text (name);
      if (!msg)
	{
	  msg = (char **)ck_malloc (sizeof (char *) * 2);
	  msg[0] = mk_sprintf ("No built in help for %s.", name);
	  msg[1] = 0;
	}
      ib = find_or_make_info (info_name);
      ib->len = parray_len (msg);
      ib->text = msg;
    }

  {
    char exp_name[200];
    char command[250];
    struct info_buffer * expanded;
    sprintf (exp_name, "_expanded_%s", info_name);
    expanded = find_or_make_info (exp_name);
    clear_info (expanded);
    expand_help_msg (expanded, ib);
    sprintf (command, "{set-info %s}", exp_name);
    run_string_as_macro (command);
  }
}
コード例 #11
0
static int opal_timer_linux_find_freq(void)
{
    FILE *fp;
    char *loc;
    float cpu_f;
    int ret;
    char buf[1024];

    fp = fopen("/proc/cpuinfo", "r");
    if (NULL == fp) {
        return OPAL_ERR_IN_ERRNO;
    }

    opal_timer_linux_freq = 0;

#if OPAL_ASSEMBLY_ARCH == OPAL_ARM64
	opal_timer_linux_freq = opal_sys_timer_freq();
#endif

    if (0 == opal_timer_linux_freq) {
        /* first, look for a timebase field.  probably only on PPC,
           but one never knows */
        loc = find_info(fp, "timebase", buf, 1024);
        if (NULL != loc) {
            int freq;
            ret = sscanf(loc, "%d", &freq);
            if (1 == ret) {
                opal_timer_linux_freq = freq;
            }
        }
    }

    if (0 == opal_timer_linux_freq) {
        /* find the CPU speed - most timers are 1:1 with CPU speed */
        loc = find_info(fp, "cpu MHz", buf, 1024);
        if (NULL != loc) {
            ret = sscanf(loc, "%f", &cpu_f);
            if (1 == ret) {
                /* numer is in MHz - convert to Hz and make an integer */
                opal_timer_linux_freq = (opal_timer_t) (cpu_f * 1000000);
            }
        }
    }

    if (0 == opal_timer_linux_freq) {
        /* look for the sparc way of getting cpu frequency */
        loc = find_info(fp, "Cpu0ClkTck", buf, 1024);
        if (NULL != loc) {
            unsigned int freq;
            ret = sscanf(loc, "%x", &freq);
            if (1 == ret) {
                opal_timer_linux_freq = freq;
            }
        }
    }

    fclose(fp);

    /* convert the timer frequency to MHz to avoid an extra operation when
     * converting from cycles to usec */
    opal_timer_linux_freq /= 1000000;

    return OPAL_SUCCESS;
}