コード例 #1
0
ファイル: param.c プロジェクト: Someone101/aleph
// increment value
io_t inc_param_value(u32 idx,  io_t inc) {
  io_t in;
  s32 scaled;

  print_dbg("\r\n inc_param_value, index: ");
  print_dbg_ulong(idx);

  print_dbg(" , input: 0x");
  print_dbg_hex(get_param_value(idx));

  print_dbg(" , increment: 0x");
  print_dbg_hex(inc);


  in = get_param_value(idx);
  // use scaler to increment and lookup
  scaled = scaler_inc( &(net->params[idx].scaler), &in, inc);

  print_dbg(" , new input: 0x");
  print_dbg_hex(in);

  print_dbg(" , scaled: 0x");
  print_dbg_hex(scaled);

  print_dbg("\r\n\r\n ");

  // store input value in pnode
  net->params[idx].data.value = in;
  net->params[idx].data.changed = 1;
  ctl_param_change(idx, scaled );  

  return in;
			   
}
コード例 #2
0
ファイル: mnemo_1-5.c プロジェクト: Frozenhorns/project
void	st(char **params, t_champ *champ, t_vm *vm, int flag)
{
  to_int	size;
  int	addr;
  to_int	reg;

  size.value = 0;
  reg.value = champ->reg[(int)params[1][1] - 1];
  get_param_value(&size, params[2], champ);
  addr = (size.value % IDX_MOD) + champ->data[ADDR] + champ->data[PC]
    + 2 + get_size_param(params[2][0]);
  addr = addr % MEM_SIZE;
  params[0][0] = ACTIF;
  if (params[2][0] == T_REG)
    champ->reg[(int)params[2][1] - 1] = champ->reg[(int)params[1][1] - 1];
  else
    {
      if (!flag || (addr >= champ->data[ADDR] &&
		    addr <= champ->data[ADDR] + champ->prog_size))
	modif_mem_case(champ, vm->mem, reg.param, addr);
    }
  color_mem_case(champ, vm->mem, params[0]);
  if (vm->no_graph == EXIT_FAILURE)
    my_printf("[%d] st (r%d=%d -> i@pc+%d)\n", champ->data[PC],
	      (int)params[1][1], reg.value, size.value);
  champ->data[PC] = (champ->data[PC] + params[0][1]) % MEM_SIZE;
}
コード例 #3
0
ファイル: dmqnode.c プロジェクト: adubovikov/kamailio
/**
 * @brief set the parameters for the node
 */
int set_dmq_node_params(dmq_node_t *node, param_t *params)
{
	str *status;
	if(!params) {
		LM_DBG("no parameters given\n");
		return 0;
	}
	status = get_param_value(params, &dmq_node_status_str);
	if(status) {
		if(STR_EQ(*status, dmq_node_active_str)) {
			node->status = DMQ_NODE_ACTIVE;
		} else if(STR_EQ(*status, dmq_node_timeout_str)) {
			node->status = DMQ_NODE_TIMEOUT;
		} else if(STR_EQ(*status, dmq_node_disabled_str)) {
			node->status = DMQ_NODE_DISABLED;
		} else if(STR_EQ(*status, dmq_node_pending_str)) {
			node->status = DMQ_NODE_PENDING;
		} else {
			LM_ERR("invalid status parameter: %.*s\n", STR_FMT(status));
			goto error;
		}
	}
	return 0;
error:
	return -1;
}
コード例 #4
0
static void template_send_form_method(int idx, struct template_content *tpc)
{
  if (get_param_value(idx, "dontpost"))
    dprintf(idx, "GET");
  else
    dprintf(idx, "POST");
}
コード例 #5
0
ファイル: tm.c プロジェクト: illwieckz/qstat
query_status_t send_tm_request_packet( struct qserver *server )
{
	char buf[2048];
	char *xmlp = buf + 8;
	unsigned int len;
	char *user = get_param_value( server, "user", NULL );
	char *password = get_param_value( server, "password", NULL );

	if ( ! server->protocol_version )
	{
		// No seen the version yet wait
		// register_send here to ensure that timeouts function correctly
		return register_send( server );
	}

	// build the query xml
	len = sprintf( xmlp, TM_XML_PREFIX );

	if ( user != NULL && password != NULL )
	{
		len += sprintf( xmlp + len, TM_AUTH_TEMPLATE, user, password );
	}
	else
	{
		// Default to User / User
		len += sprintf( xmlp + len, TM_AUTH_TEMPLATE, "User", "User" );
	}

	// Always get Player info otherwise player count is invalid
	// TODO: add more calls to get full player info?
	server->flags |= TF_PLAYER_QUERY|TF_RULES_QUERY;
	len += sprintf( xmlp + len, TM_SERVERINFO );
	len += sprintf( xmlp + len, TM_PLAYERLIST );
	len += sprintf( xmlp + len, TM_XML_SUFFIX );

	// First 4 bytes is the length of the request
	memcpy( buf, &len, 4 );
	// Second 4 bytes is the handle identifier ( id )
	memcpy( buf+4, &server->challenge, 4 );

	// prep the details we need for multi packet responses
	// we expect at least 1 packet response
	server->saved_data.pkt_max = 1;

	return send_packet( server, buf, len + 8 );
}
コード例 #6
0
ファイル: facedetect.cpp プロジェクト: ttill/frei0r
    void update()
    {
        if (!cascade) {
            cvSetNumThreads(cvRound(threads * 100));
            f0r_param_string classifier;
            get_param_value(&classifier, FACEBL0R_PARAM_CLASSIFIER);
            if (classifier) {
                cascade = (CvHaarClassifierCascade*) cvLoad(classifier, 0, 0, 0 );
                if (!cascade)
                    fprintf(stderr, "ERROR: Could not load classifier cascade %s\n", classifier);
                storage = cvCreateMemStorage(0);
            }
            else {
                memcpy(out, in, size * 4);
                return;
            }
        }
        
        // copy input image to OpenCV
        if( !image )
            image = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 4);
        memcpy(image->imageData, in, size * 4);
        
        // only re-detect periodically to control performance and reduce shape jitter
        int recheckInt = abs(cvRound(recheck * 1000));
        if ( recheckInt > 0 && count % recheckInt )
        {
            // skip detect
            count++;
//            fprintf(stderr, "draw-only counter %u\n", count);
        }
        else
        {
            count = 1;   // reset the recheck counter
            if (objects) // reset the list of objects
                cvClearSeq(objects);
            
            double elapsed = (double) cvGetTickCount();

            objects = detect();

            // use detection time to throttle frequency of re-detect vs. redraw (automatic recheck)
            elapsed = cvGetTickCount() - elapsed;
            elapsed = elapsed / ((double) cvGetTickFrequency() * 1000.0);

            // Automatic recheck uses an undocumented negative parameter value,
            // which is not compliant, but technically feasible.
            if (recheck < 0 && cvRound( elapsed / (1000.0 / (recheckInt + 1)) ) <= recheckInt)
                    count += recheckInt - cvRound( elapsed / (1000.0 / (recheckInt + 1)));
//            fprintf(stderr, "detection time = %gms counter %u\n", elapsed, count);
        }
        
        draw();
        
        // copy filtered OpenCV image to output
        memcpy(out, image->imageData, size * 4);
        cvReleaseImage(&image);
    }
コード例 #7
0
ファイル: net.c プロジェクト: bensteinberg/aleph
//--- get / set / increment input value
io_t net_get_in_value(s32 inIdx) {
  if(inIdx < 0) {
    return 0;
  }
  if (inIdx >= net->numIns) {
    inIdx -= net->numIns;
    return get_param_value(inIdx);
  } else {
    return op_get_in_val(net->ops[net->ins[inIdx].opIdx], net->ins[inIdx].opInIdx);
  }
}
コード例 #8
0
ファイル: fsp_params.c プロジェクト: pcengines/coreboot
static void parse_devicetree_param(const config_t *config, FSP_S_CONFIG *params)
{
	uint32_t dev_offset = 0;
	uint32_t i = 0;

	for (i = 0; i < CONFIG_SOC_INTEL_I2C_DEV_MAX; i++, dev_offset++) {
		params->SerialIoI2cMode[i] =
				get_param_value(config, dev_offset);
	}

	for (i = 0; i < CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX; i++,
	     dev_offset++) {
		params->SerialIoSpiMode[i] =
				get_param_value(config, dev_offset);
	}

	for (i = 0; i < SOC_INTEL_CML_UART_DEV_MAX; i++, dev_offset++) {
		params->SerialIoUartMode[i] =
				get_param_value(config, dev_offset);
	}
}
コード例 #9
0
ファイル: ts3.c プロジェクト: multiplay/qstat
query_status_t
send_ts3_all_servers_packet(struct qserver *server)
{
	char buf[256], *password, *username;

	switch (server->challenge) {
	case 0:
		// Not seen a challenge yet, wait for it
		server->n_servers = 999;
		return (INPROGRESS);

	case 1:
		password = get_param_value(server, "password", "");
		if (0 != strlen(password)) {
			username = get_param_value(server, "username", "serveradmin");
			sprintf(buf, "login %s %s\015\012", username, password);
			break;
		}
		// NOTE: no break so we fall through
		server->challenge++;

	case 2:
		// NOTE: we currently don't support player info
		server->flags |= TF_STATUS_QUERY;
		server->n_servers = 3;
		sprintf(buf, "serverlist\015\012");
		break;

	case 3:
		sprintf(buf, "quit\015\012");
		break;

	case 4:
		return (DONE_FORCE);
	}

	server->saved_data.pkt_max = -1;

	return (send_packet(server, buf, strlen(buf)));
}
コード例 #10
0
ファイル: doom3.c プロジェクト: JasonRivers/qstat
static unsigned put_param_string(struct qserver* server, const char* paramname, char* buf, unsigned buflen, unsigned off)
{
	char* val = get_param_value( server, paramname, NULL);
	if(val && strlen(val) < buflen-off-2)
	{
		strcpy(buf+off, val);
		off += strlen(val) + 1;
	}
	else
	{
		buf[off++] = '\0';
	}

	return off;
}
コード例 #11
0
int load_configuration_file (FILE* config_file,CONFIG* config_struct ){
	char line[257] ; 
	int cur_val ;
	char cur_param [256] ; 
	int x = 0 ;
	while(fgets(line,256,config_file) !=NULL){
		if (strlen(line) <= 1 || contain_ch (line,'=')==false ) 
			continue ; 
	cur_val = get_param_value(line,cur_param);
	x= update_field(config_struct,cur_param,cur_val) ;
	assert(x!=0);

	}

	return 1 ;
}
コード例 #12
0
ファイル: param.c プロジェクト: nvl1109/em2440iii
/* 
 * Change a value of parameter
 *
 * vivi> param set <name> <value>
 *
 *     set (argv[0]): command of parameter
 *  <name> (argv[1]): name of parameter
 * <value> (argv[2]): value to set
 */
static void command_set(int argc, const char **argv)
{
	int ret;
	char *name;
	param_value_t pre_value, value;


	if (argc != 3) {
		printk("invalid 'param set' command: too few(many) arguments\n");
		return;
	}

	/* parsing arguments */
	name = (char *)argv[1];

	/* if a user want to set the 'linux command line' */
	if (strncmp(name, "linux_cmd_line", strlen(name)) == 0) {
		ret = set_linux_cmd_line(argv[2]);
		if (!ret) {
			printk("Change linux command line to \"%s\"\n", 
				linux_cmd_line);
		} else {
			printk("Failed changing linux command line\n");
		}
		return;
	}

	/* Change normag vivi parameters */
	value = (param_value_t)strtoul(argv[2], NULL, 0, &ret);
	if (ret) {
		printk("Can not parsing arguments\n");
	}

	pre_value = get_param_value(name, &ret);
	ret = set_param_value(name, value);
	if (ret) {
		printk("Error: can not change '%s' parameter value\n", name);
	}
	printk("Change '%s' value. 0x%08lx(%d) to 0x%08lx(%d)\n",
		name, pre_value, pre_value, value, value);
	return;
}
コード例 #13
0
ファイル: dirtybomb.c プロジェクト: JasonRivers/qstat
query_status_t
send_dirtybomb_request_packet(struct qserver *server)
{
	char buf[1024], *password, chunks, len;

	password = get_param_value(server, "password", "");
	len = strlen(password);
	chunks = 0x01;
	if (server->flags & TF_RULES_QUERY) {
		chunks |= 0x02;
	}
	if (server->flags & TF_PLAYER_QUERY) {
		chunks |= 0x04; // Player
		chunks |= 0x08; // Team - Currently not supported
	}
	sprintf(buf, "%c%c%s%c", 0x01, len, password, chunks);

	server->saved_data.pkt_max = -1;

	return send_packet(server, buf, len + 3);
}
コード例 #14
0
ファイル: crysis.c プロジェクト: multiplay/qstat
query_status_t
send_crysis_request_packet(struct qserver *server)
{
	char cmd[256], buf[1024], *password, *md5;

	debug(2, "challenge: %ld", server->challenge);
	switch (server->challenge) {
	case 0:
		// Not seen a challenge yet, request it
		server->challenge++;
		sprintf(cmd, "challenge");
		break;

	case 1:
		server->challenge++;
		password = get_param_value(server, "password", "");
		sprintf(cmd, "%s:%s", server->challenge_string, password);
		md5 = md5_hex(cmd, strlen(cmd));
		sprintf(cmd, "authenticate %s", md5);
		free(md5);
		break;

	case 2:
		// NOTE: we currently don't support player info
		server->challenge++;
		server->flags |= TF_STATUS_QUERY;
		server->n_servers = 3;
		sprintf(cmd, "status");
		break;

	case 3:
		return (DONE_FORCE);
	}

	server->saved_data.pkt_max = -1;
	sprintf(buf, "POST /RPC2 HTTP/1.1\015\012Keep-Alive: 300\015\012User-Agent: qstat %s\015\012Content-Length: %d\015\012Content-Type: text/xml\015\012\015\012<?xml version=\"1.0\" encoding=\"UTF-8\"?><methodCall><methodName>%s</methodName><params /></methodCall>", VERSION, (int)(98 + strlen(cmd)), cmd);

	return (send_packet(server, buf, strlen(buf)));
}
コード例 #15
0
ファイル: mnemo_1-5.c プロジェクト: Frozenhorns/project
void    ld(char **params, t_champ *champ, t_vm *vm, int flag)
{
  to_int	size;
  int		value;

  size.value = 0;
  value = 0;
  get_param_value(&size, params[1], champ);
  params[0][0] = ACTIF;
  if (params[1][0] == T_REG)
    champ->reg[(int)params[2][1] - 1] = champ->reg[(int)params[1][1] - 1];
  else if (params[1][0] == T_IND)
    ld_ind(flag, champ, vm, params);
  if (params[1][0] == T_DIR)
    champ->reg[(int)params[2][1] - 1] = size.value;
  color_mem_case(champ, vm->mem, params[0]);
  champ->data[PC] = (champ->data[PC] + params[0][1]) % MEM_SIZE;
  if (vm->no_graph == EXIT_FAILURE)
    my_printf("[%d] ld (d=%d -> r%d) carry=%d\n", champ->data[PC], size.value,
	      (int)params[2][1], champ->data[CARRY]);
  champ->data[CARRY] != 1 ? (champ->data[CARRY] = 1) : (42);
}
コード例 #16
0
static void armadillo8x0_setup_console(struct platform_info *pinfo)
{
	char console[128];
	int ret;
	int autoboot = armadillo8x0_is_autoboot(pinfo);

#if defined(CONFIG_CMD_SETENV)
	ret = get_param_value("console", console, 128);
	if (ret == 0 && strcmp(console, "none") == 0)
		if (!autoboot)
			ret = 1;
	if (ret)
#endif
		hsprintf(console, "%s", CONFIG_DEFAULT_CONSOLE);

	/* we must set up to STANDARD_CONSOLE to match our hardware.
	   FIXME: this is redundant and just using a side effect of
	   the function to initialize it */
	change_console(CONFIG_STANDARD_CONSOLE);
	ret = change_console(console);
	if (ret && !autoboot)
		change_console(CONFIG_STANDARD_CONSOLE);
}
コード例 #17
0
ファイル: acpi.c プロジェクト: Blopeur/qemu-heca
/* XXX fixme: this function uses obsolete argument parsing interface */
int acpi_table_add(const char *t)
{
    char buf[1024], *p, *f;
    unsigned long val;
    size_t len, start, allen;
    bool has_header;
    int changed;
    int r;
    struct acpi_table_header hdr;

    r = 0;
    r |= get_param_value(buf, sizeof(buf), "data", t) ? 1 : 0;
    r |= get_param_value(buf, sizeof(buf), "file", t) ? 2 : 0;
    switch (r) {
    case 0:
        buf[0] = '\0';
        /* fallthrough for default behavior */
    case 1:
        has_header = false;
        break;
    case 2:
        has_header = true;
        break;
    default:
        fprintf(stderr, "acpitable: both data and file are specified\n");
        return -1;
    }

    if (!acpi_tables) {
        allen = sizeof(uint16_t);
        acpi_tables = g_malloc0(allen);
    } else {
        allen = acpi_tables_len;
    }

    start = allen;
    acpi_tables = g_realloc(acpi_tables, start + ACPI_TABLE_HDR_SIZE);
    allen += has_header ? ACPI_TABLE_PFX_SIZE : ACPI_TABLE_HDR_SIZE;

    /* now read in the data files, reallocating buffer as needed */

    for (f = strtok(buf, ":"); f; f = strtok(NULL, ":")) {
        int fd = open(f, O_RDONLY | O_BINARY);

        if (fd < 0) {
            fprintf(stderr, "can't open file %s: %s\n", f, strerror(errno));
            return -1;
        }

        for (;;) {
            char data[8192];
            r = read(fd, data, sizeof(data));
            if (r == 0) {
                break;
            } else if (r > 0) {
                acpi_tables = g_realloc(acpi_tables, allen + r);
                memcpy(acpi_tables + allen, data, r);
                allen += r;
            } else if (errno != EINTR) {
                fprintf(stderr, "can't read file %s: %s\n",
                        f, strerror(errno));
                close(fd);
                return -1;
            }
        }

        close(fd);
    }

    /* now fill in the header fields */

    f = acpi_tables + start;   /* start of the table */
    changed = 0;

    /* copy the header to temp place to align the fields */
    memcpy(&hdr, has_header ? f : dfl_hdr, ACPI_TABLE_HDR_SIZE);

    /* length of the table minus our prefix */
    len = allen - start - ACPI_TABLE_PFX_SIZE;

    hdr._length = cpu_to_le16(len);

    if (get_param_value(buf, sizeof(buf), "sig", t)) {
        /* strncpy is justified: the field need not be NUL-terminated. */
        strncpy(hdr.sig, buf, sizeof(hdr.sig));
        ++changed;
    }

    /* length of the table including header, in bytes */
    if (has_header) {
        /* check if actual length is correct */
        val = le32_to_cpu(hdr.length);
        if (val != len) {
            fprintf(stderr,
                "warning: acpitable has wrong length,"
                " header says %lu, actual size %zu bytes\n",
                val, len);
            ++changed;
        }
    }
    /* we may avoid putting length here if has_header is true */
    hdr.length = cpu_to_le32(len);

    if (get_param_value(buf, sizeof(buf), "rev", t)) {
        val = strtoul(buf, &p, 0);
        if (val > 255 || *p) {
            fprintf(stderr, "acpitable: \"rev=%s\" is invalid\n", buf);
            return -1;
        }
        hdr.revision = (uint8_t)val;
        ++changed;
    }

    if (get_param_value(buf, sizeof(buf), "oem_id", t)) {
        /* strncpy is justified: the field need not be NUL-terminated. */
        strncpy(hdr.oem_id, buf, sizeof(hdr.oem_id));
        ++changed;
    }

    if (get_param_value(buf, sizeof(buf), "oem_table_id", t)) {
        /* strncpy is justified: the field need not be NUL-terminated. */
        strncpy(hdr.oem_table_id, buf, sizeof(hdr.oem_table_id));
        ++changed;
    }

    if (get_param_value(buf, sizeof(buf), "oem_rev", t)) {
        val = strtol(buf, &p, 0);
        if (*p) {
            fprintf(stderr, "acpitable: \"oem_rev=%s\" is invalid\n", buf);
            return -1;
        }
        hdr.oem_revision = cpu_to_le32(val);
        ++changed;
    }

    if (get_param_value(buf, sizeof(buf), "asl_compiler_id", t)) {
        /* strncpy is justified: the field need not be NUL-terminated. */
        strncpy(hdr.asl_compiler_id, buf, sizeof(hdr.asl_compiler_id));
        ++changed;
    }

    if (get_param_value(buf, sizeof(buf), "asl_compiler_rev", t)) {
        val = strtol(buf, &p, 0);
        if (*p) {
            fprintf(stderr, "acpitable: \"%s=%s\" is invalid\n",
                    "asl_compiler_rev", buf);
            return -1;
        }
        hdr.asl_compiler_revision = cpu_to_le32(val);
        ++changed;
    }

    if (!has_header && !changed) {
        fprintf(stderr, "warning: acpitable: no table headers are specified\n");
    }


    /* now calculate checksum of the table, complete with the header */
    /* we may as well leave checksum intact if has_header is true */
    /* alternatively there may be a way to set cksum to a given value */
    hdr.checksum = 0;    /* for checksum calculation */

    /* put header back */
    memcpy(f, &hdr, sizeof(hdr));

    if (changed || !has_header || 1) {
        ((struct acpi_table_header *)f)->checksum =
            acpi_checksum((uint8_t *)f + ACPI_TABLE_PFX_SIZE, len);
    }

    /* increase number of tables */
    (*(uint16_t *)acpi_tables) =
        cpu_to_le32(le32_to_cpu(*(uint16_t *)acpi_tables) + 1);

    acpi_tables_len = allen;
    return 0;

}
コード例 #18
0
static void template_send_if_dontpost(int idx, struct template_content *tpc)
{
  if (get_param_value(idx, "dontpost"))
    templates_content_send(tpc->subcontent, idx);
}
コード例 #19
0
ファイル: acpi.c プロジェクト: AjayMashi/nitro-kvm
int acpi_table_add(const char *t)
{
    static const char *dfl_id = "QEMUQEMU";
    char buf[1024], *p, *f;
    struct acpi_table_header acpi_hdr;
    unsigned long val;
    size_t off;

    memset(&acpi_hdr, 0, sizeof(acpi_hdr));
  
    if (get_param_value(buf, sizeof(buf), "sig", t)) {
        strncpy(acpi_hdr.signature, buf, 4);
    } else {
        strncpy(acpi_hdr.signature, dfl_id, 4);
    }
    if (get_param_value(buf, sizeof(buf), "rev", t)) {
        val = strtoul(buf, &p, 10);
        if (val > 255 || *p != '\0')
            goto out;
    } else {
        val = 1;
    }
    acpi_hdr.revision = (int8_t)val;

    if (get_param_value(buf, sizeof(buf), "oem_id", t)) {
        strncpy(acpi_hdr.oem_id, buf, 6);
    } else {
        strncpy(acpi_hdr.oem_id, dfl_id, 6);
    }

    if (get_param_value(buf, sizeof(buf), "oem_table_id", t)) {
        strncpy(acpi_hdr.oem_table_id, buf, 8);
    } else {
        strncpy(acpi_hdr.oem_table_id, dfl_id, 8);
    }

    if (get_param_value(buf, sizeof(buf), "oem_rev", t)) {
        val = strtol(buf, &p, 10);
        if(*p != '\0')
            goto out;
    } else {
        val = 1;
    }
    acpi_hdr.oem_revision = cpu_to_le32(val);

    if (get_param_value(buf, sizeof(buf), "asl_compiler_id", t)) {
        strncpy(acpi_hdr.asl_compiler_id, buf, 4);
    } else {
        strncpy(acpi_hdr.asl_compiler_id, dfl_id, 4);
    }

    if (get_param_value(buf, sizeof(buf), "asl_compiler_rev", t)) {
        val = strtol(buf, &p, 10);
        if(*p != '\0')
            goto out;
    } else {
        val = 1;
    }
    acpi_hdr.asl_compiler_revision = cpu_to_le32(val);
    
    if (!get_param_value(buf, sizeof(buf), "data", t)) {
         buf[0] = '\0';
    }

    acpi_hdr.length = sizeof(acpi_hdr);

    f = buf;
    while (buf[0]) {
        struct stat s;
        char *n = strchr(f, ':');
        if (n)
            *n = '\0';
        if(stat(f, &s) < 0) {
            fprintf(stderr, "Can't stat file '%s': %s\n", f, strerror(errno));
            goto out;
        }
        acpi_hdr.length += s.st_size;
        if (!n)
            break;
        *n = ':';
        f = n + 1;
    }

    if (!acpi_tables) {
        acpi_tables_len = sizeof(uint16_t);
        acpi_tables = qemu_mallocz(acpi_tables_len);
    }
    p = acpi_tables + acpi_tables_len;
    acpi_tables_len += sizeof(uint16_t) + acpi_hdr.length;
    acpi_tables = qemu_realloc(acpi_tables, acpi_tables_len);

    acpi_hdr.length = cpu_to_le32(acpi_hdr.length);
    *(uint16_t*)p = acpi_hdr.length;
    p += sizeof(uint16_t);
    memcpy(p, &acpi_hdr, sizeof(acpi_hdr));
    off = sizeof(acpi_hdr);

    f = buf;
    while (buf[0]) {
        struct stat s;
        int fd;
        char *n = strchr(f, ':');
        if (n)
            *n = '\0';
        fd = open(f, O_RDONLY);

        if(fd < 0)
            goto out;
        if(fstat(fd, &s) < 0) {
            close(fd);
            goto out;
        }

        do {
            int r;
            r = read(fd, p + off, s.st_size);
            if (r > 0) {
                off += r;
                s.st_size -= r;
            } else if ((r < 0 && errno != EINTR) || r == 0) {
                close(fd);
                goto out;
            }
        } while(s.st_size);

        close(fd);
        if (!n)
            break;
        f = n + 1;
    }

    ((struct acpi_table_header*)p)->checksum = acpi_checksum((uint8_t*)p, off);
    /* increase number of tables */
    (*(uint16_t*)acpi_tables) =
	    cpu_to_le32(le32_to_cpu(*(uint16_t*)acpi_tables) + 1);
    return 0;
out:
    if (acpi_tables) {
        qemu_free(acpi_tables);
        acpi_tables = NULL;
    }
    return -1;
}
コード例 #20
0
ファイル: respmod.c プロジェクト: dankamongmen/snare
static int
extract_reqmod_data(const char *data, SiteInfoType *si, unsigned int *eid,
		    unsigned int *pid, unsigned int *uid, unsigned int *gid) {
  int ret = -1;
  char *enc = NULL, *dec = NULL, *dummy_url = NULL;
  ParamNodeType *pl = NULL;
  const char *s, *bldata;
  size_t len_output;
  uint32_t _eid, _pid, _uid, _gid;

  enc = Strdup(data);
  if(!enc) {
    goto cleanup;
  }

  nag("Processing policy data header: %s\n", enc);

  dec = (char *)decrypt_data(poldata_key, strlen(poldata_key),
			     enc, &len_output);
  if(!dec) {
    goto cleanup;
  }
  nag("Decrypted: %s\n", dec);

  pl = parse_params(dec, "&");

#define GET_PARAM_VAL(param) \
  if(!(s = get_param_value(pl, #param, 0))) { \
    nag(#param " param not found\n"); \
    goto cleanup; \
  } \
  if(lex_u32(&s, &_ ## param)) { \
    nag("Error lexing " #param " [%s]\n", s); \
    goto cleanup; \
  }

  GET_PARAM_VAL(eid)
  GET_PARAM_VAL(pid)
  GET_PARAM_VAL(uid)
  GET_PARAM_VAL(gid)

#undef GET_PARAM_VAL

  // si
  bldata = get_param_value(pl, "bldata", 0);
  if(!decode_block_page_data(bldata, &dummy_url, si, 0)) { // returns false on error... argh!
    nag("Error decoding meta data\n");
    goto cleanup; 
  }

  *eid = _eid;
  *pid = _pid;
  *uid = _uid;
  *gid = _gid;

  ret = 0;
 cleanup:
  Free(dummy_url);
  Free(enc);
  Free(dec);
  delete_param_list(pl);
  return ret;
}
コード例 #21
0
ファイル: doom3.c プロジェクト: JasonRivers/qstat
static char* build_doom3_masterfilter(struct qserver* server, char* buf, unsigned* buflen, int q4)
{
	int flen = 0;
	char *pkt, *r, *sep= "";
	unsigned char b = 0;
	char *proto = server->query_arg;
	unsigned ver;
	unsigned off = 13;

	if(!proto)
	{
		if(q4)
		{
			*buflen = sizeof(quake4_master_query);
			return (char*)quake4_master_query;
		}
		else
		{
			*buflen = sizeof(doom3_master_query);
			return (char*)doom3_master_query;
		}
	}

	ver = (atoi(proto) & 0xFFFF) << 16;
	proto = strchr(proto, '.');
	if(proto && *++proto)
	{
		ver |= (atoi(proto) & 0xFFFF);
	}
	if(q4)
	{
		ver |= 1 << 31; // third party flag
	}
	memcpy(buf, doom3_master_query, sizeof(doom3_master_query));
	put_long_little(ver, buf+off);
	off += 4;

	off = put_param_string(server, "game", buf, *buflen, off);

	if(q4)
	{
		off = put_param_string(server, "player", buf, *buflen, off);
		off = put_param_string(server, "clan", buf, *buflen, off);
	}

	pkt = get_param_value( server, "status", NULL);
	r = pkt ;
	while ( pkt && sep )
	{
		sep= strchr( r, ':');
		if ( sep )
			flen= sep-r;
		else
			flen= strlen(r);

		if ( strncmp( r, "password", flen) == 0)
			b |= 0x01;
		else if ( strncmp( r, "nopassword", flen) == 0)
			b |= 0x02;
		else if ( strncmp( r, "notfull", flen) == 0)
			b |= 0x04;
		else if ( strncmp( r, "notfullnotempty", flen) == 0)
			b |= 0x08;
		r= sep+1;
	}

	pkt = get_param_value( server, "gametype", NULL);
	if(pkt)
	{
		if ( strncmp( pkt, "dm", flen) == 0)
			b |= 0x10;
		else if ( strncmp( pkt, "tourney", flen) == 0)
			b |= 0x20;
		else if ( strncmp( pkt, "tdm", flen) == 0)
			b |= 0x30;
	}

	buf[off++] = (char)b;
	*buflen = off;

	return buf;
}
コード例 #22
0
ファイル: fsp_params.c プロジェクト: pcengines/coreboot
static void parse_devicetree_param(const config_t *config, FSP_S_CONFIG *params)
{
	for (int i = 0; i < ARRAY_SIZE(serial_io_dev); i++)
		params->SerialIoDevMode[i] = get_param_value(config, i);
}
コード例 #23
0
ファイル: ts3.c プロジェクト: multiplay/qstat
query_status_t
deal_with_ts3_packet(struct qserver *server, char *rawpkt, int pktlen)
{
	char *s, *player_name = "unknown";
	int valid_response = 0, mode = 0, all_servers = 0;
	char last_char;
	unsigned short port = 0, down = 0, auth_seen = 0;

	debug(2, "processing...");

	if (0 == pktlen) {
		// Invalid password
		return (REQ_ERROR);
	}

	last_char = rawpkt[pktlen - 1];
	rawpkt[pktlen - 1] = '\0';
	s = rawpkt;
	all_servers = all_ts3_servers(server);

	debug(3, "packet: combined = %d, challenge = %ld, n_servers = %d", server->combined, server->challenge, server->n_servers);
	if (!server->combined) {
		server->retry1 = n_retries;
		if (0 == server->n_requests) {
			server->ping_total = time_delta(&packet_recv_time, &server->packet_time1);
			server->n_requests++;
		}

		if (server->n_servers >= server->challenge) {
			// response fragment recieved
			int pkt_id;
			int pkt_max;

			// We're expecting more to come
			debug(5, "fragment recieved...");
			pkt_id = packet_count(server);
			pkt_max = pkt_id + 1;
			rawpkt[pktlen - 1] = last_char; // restore the last character
			if (!add_packet(server, 0, pkt_id, pkt_max, pktlen, rawpkt, 1)) {
				// fatal error e.g. out of memory
				return (MEM_ERROR);
			}

			// combine_packets will call us recursively
			return (combine_packets(server));
		}
	} else {
		valid_response = valid_ts3_response(server, rawpkt + server->master_pkt_len, pktlen - server->master_pkt_len);

		debug(2, "combined packet: valid_response: %d, challenge: %ld, n_servers: %d, offset: %d", valid_response, server->challenge, server->n_servers, server->master_pkt_len);

		if (0 > valid_response) {
			// Error occured
			return (valid_response);
		}

		server->challenge += valid_response;

		if (valid_response) {
			// Got a valid response, send the next request
			int ret = send_ts3_request_packet(server);
			if (0 != ret) {
				// error sending packet
				debug(4, "Request failed: %d", ret);
				return (ret);
			}
		}

		if (server->n_servers > server->challenge) {
			// recursive call which is still incomplete
			return (INPROGRESS);
		}
	}

	// Correct ping
	// Not quite right but gives a good estimate
	server->ping_total = (server->ping_total * server->n_requests) / 2;

	debug(3, "processing response...");

	s = strtok(rawpkt, "\012\015 |");

	// NOTE: id=XXX and msg=XXX will be processed by the mod following the one they where the response of
	while (NULL != s) {
		debug(4, "LINE: %d, %s\n", mode, s);
		switch (mode) {
		case 0:
			// prompt, use or serverlist response
			if (0 == strcmp("TS3", s)) {
				// nothing to do unless in all servers mode
				if (1 == all_servers) {
					mode++;
				}
			} else if (0 == strncmp("error", s, 5)) {
				// end of use response
				mode++;
			}
			break;

		case 1:
			// serverinfo or serverlist response including condition authentication
			if ((0 == auth_seen) && (0 != strlen(get_param_value(server, "password", ""))) && (0 == strncmp("error", s, 5))) {
				// end of auth response
				auth_seen = 1;
			} else if (0 == strncmp("error", s, 5)) {
				// end of serverinfo response
				mode++;
			} else {
				// Server Rule
				char *key = s;
				char *value = strchr(key, '=');
				if (NULL != value) {
					*value = '\0';
					value++;
					debug(6, "Rule: %s = %s\n", key, value);
					if (0 == strcmp("virtualserver_name", key)) {
						if (1 == all_servers) {
							struct qserver *new_server = add_qserver_byaddr(ntohl(server->ipaddr), port, server->type, NULL);
							if (NULL != new_server) {
								if (down) {
									// Status indicates this server is actually offline
									new_server->server_name = DOWN;
								} else {
									new_server->max_players = server->max_players;
									new_server->num_players = server->num_players;
									new_server->server_name = strdup(decode_ts3_val(value));
									new_server->map_name = strdup("N/A");
									new_server->ping_total = server->ping_total;
									new_server->n_requests = server->n_requests;
								}
								cleanup_qserver(new_server, FORCE);
							}
							down = 0;
						} else {
							server->server_name = strdup(decode_ts3_val(value));
						}
					} else if (0 == strcmp("virtualserver_port", key)) {
						port = atoi(value);
						change_server_port(server, port, 0);
						add_rule(server, key, value, NO_FLAGS);
					} else if (0 == strcmp("virtualserver_maxclients", key)) {
						server->max_players = atoi(value);
					} else if (0 == strcmp("virtualserver_clientsonline", key)) {
						server->num_players = atoi(value);
					} else if (0 == strcmp("virtualserver_queryclientsonline", key)) {
						// clientsonline includes queryclientsonline so remove these from our count
						server->num_players -= atoi(value);
					} else if ((0 == strcmp("virtualserver_status", key)) && (0 != strcmp("online", value))) {
						// Server is actually offline to client so display as down
						down = 1;
						if (1 != all_servers) {
							server->server_name = DOWN;
							//server->saved_data.pkt_index = 0;
							return (DONE_FORCE);
						}
					} else if ((0 == strcmp("id", key)) || (0 == strcmp("msg", key))) {
						// Ignore details from the response code
					} else if (1 != all_servers) {
						add_rule(server, key, value, NO_FLAGS);
					}
				}
			}
			break;

		case 2:
			// clientlist response
			if (0 == strncmp("error", s, 5)) {
				// end of serverinfo response
				mode++;
			} else {
				// Client
				char *key = s;
				char *value = strchr(key, '=');
				if (NULL != value) {
					*value = '\0';
					value++;
					debug(6, "Player: %s = %s\n", key, value);
					if (0 == strcmp("client_nickname", key)) {
						player_name = value;
					} else if (0 == strcmp("clid", key)) {
					} else if ((0 == strcmp("client_type", key)) && (0 == strcmp("0", value))) {
						struct player *player = add_player(server, server->n_player_info);
						if (NULL != player) {
							player->name = strdup(decode_ts3_val(player_name));
						}
					} else if ((0 == strcmp("id", key)) || (0 == strcmp("msg", key))) {
						// Ignore details from the response code
					}
				}
			}
			break;
		}
		s = strtok(NULL, "\012\015 |");
	}

	gettimeofday(&server->packet_time1, NULL);

	server->map_name = strdup("N/A");
	return (DONE_FORCE);
}
コード例 #24
0
ファイル: facebl0r.cpp プロジェクト: adinapoli/frei0r
void FaceBl0r::update() {

  if (!cascade) {
      cvSetNumThreads(cvRound(threads * 100));
      get_param_value(&classifier, FACEBL0R_PARAM_CLASSIFIER);
      if (classifier && strcmp(classifier, "")) {
	if ( strcmp(classifier, old_classifier) == 0) {
	  // same as before, avoid repeating error messages
	  memcpy(out, in, size * 4); // of course assuming we are RGBA only
	  return;
	} else strcpy(old_classifier, classifier);

	cascade = (CvHaarClassifierCascade*) cvLoad(classifier, 0, 0, 0 );
	if (!cascade) {
	  fprintf(stderr, "ERROR in filter facebl0r, classifier cascade not found:\n");
	  fprintf(stderr, " %s\n", classifier);
	  memcpy(out, in, size * 4);
	  return;
	}
	storage = cvCreateMemStorage(0);
      }
      else {
	memcpy(out, in, size * 4);
	return;
      }
  }

  // sanitize parameters
  recheck = CLAMP(recheck, 0.001, 1.0);
  search_scale = CLAMP(search_scale, 0.11, 1.0);
  neighbors = CLAMP(neighbors, 0.01, 1.0);

  if( !image )
      image = cvCreateImage( cvSize(width,height), IPL_DEPTH_8U, 4 );

  memcpy(image->imageData, in, size * 4);

  /*
    no face*
     - look for (detect_face)
    yes face
     - track face
     - no more face
       no face*
   */
  if(face_notfound>0) {

      if(face_notfound % cvRound(recheck * 1000) == 0)
          face_rect = detect_face(image, cascade, storage);

      // if no face detected
      if (!face_rect) {
          face_notfound++;
      } else {
          //track detected face with camshift
          if(tracked_obj)
              destroy_tracked_object(tracked_obj);
          tracked_obj = create_tracked_object(image, face_rect);
          face_notfound = 0;
          face_found++;
      }

  }

  if(face_found>0) { 
      //track the face in the new frame
      face_box = camshift_track_face(image, tracked_obj);

      int min = cvRound(smallest * 1000);
          min = min? min : 10;
      int max = cvRound(largest * 10000);
      if( ( face_box.size.width < min )
          || (face_box.size.height < min )
          || (face_box.size.width > max )
          || (face_box.size.height > max )
          ) {
          face_found = 0;
          face_notfound++;
      }
      else {
////////////////////////////////////////////////////////////////////////
	      cvSetImageROI (image, tracked_obj->prev_rect);
//          cvSmooth (image, image, CV_BLUR, 22, 22, 0, 0);
		  cvSmooth (image, image, CV_BLUR, 23, 23, 0, 0);
//          cvSmooth (image, image, CV_GAUSSIAN, 11, 11, 0, 0);
		  cvResetImageROI (image);
////////////////////////////////////////////////////////////////////////
      
          //outline face ellipse
          if (ellipse)
              cvEllipseBox(image, face_box, CV_RGB(255,0,0), 2, CV_AA, 0);

          face_found++;
          if(face_found % cvRound(recheck * 1000) == 0)
              face_notfound = cvRound(recheck * 1000); // try recheck
      }
  }

  memcpy(out, image->imageData, size * 4);
  cvReleaseImage(&image);
}
コード例 #25
0
/******************************************************************************
 *                                                                            *
 * Function: get_value_db                                                     *
 *                                                                            *
 * Purpose: retrieve data from database                                       *
 *                                                                            *
 * Parameters: item - item we are interested in                               *
 *                                                                            *
 * Return value: SUCCEED - data successfully retrieved and stored in result   *
 *               NOTSUPPORTED - requested item is not supported               *
 *                                                                            *
 * Author: Eugene Grigorjev                                                   *
 *                                                                            *
 * Comments:                                                                  *
 *                                                                            *
 ******************************************************************************/
int	get_value_db(DC_ITEM *item, AGENT_RESULT *result)
{
	const char	*__function_name = "get_value_db";
#ifdef HAVE_ODBC
	ZBX_ODBC_DBH	dbh;
	ZBX_ODBC_ROW	row;
	char		*db_dsn = NULL, *db_user = NULL, *db_pass = NULL, *db_sql = NULL;
#endif
	int		ret = NOTSUPPORTED;

	init_result(result);

	zabbix_log(LOG_LEVEL_DEBUG, "In %s() key_orig:'%s'", __function_name, item->key_orig);

#ifdef HAVE_ODBC

#define DB_ODBC_SELECT_KEY	"db.odbc.select["

	if (0 == strncmp(item->key, DB_ODBC_SELECT_KEY, strlen(DB_ODBC_SELECT_KEY)))
	{
		db_dsn = get_param_value(item->params, "DSN");
		db_user = get_param_value(item->params, "user");
		db_pass = get_param_value(item->params, "password");
		db_sql = get_param_value(item->params, "sql");

		if (SUCCEED == odbc_DBconnect(&dbh, db_dsn, db_user, db_pass, CONFIG_TIMEOUT))
		{
			if (NULL != odbc_DBselect(&dbh, db_sql))
			{
				if (NULL != (row = odbc_DBfetch(&dbh)))
				{
					if (NULL == row[0])
					{
						SET_MSG_RESULT(result, zbx_strdup(NULL, "SQL query returned NULL "
								"value."));
					}
					else if (SUCCEED == set_result_type(result, item->value_type, item->data_type,
							row[0]))
					{
						ret = SUCCEED;
					}
				}
				else
				{
					const char	*last_error = get_last_odbc_strerror();

					if ('\0' != *last_error)
						SET_MSG_RESULT(result, zbx_strdup(NULL, last_error));
					else
						SET_MSG_RESULT(result, zbx_strdup(NULL, "SQL query returned empty "
								"result."));
				}
			}
			else
				SET_MSG_RESULT(result, zbx_strdup(NULL, get_last_odbc_strerror()));

			odbc_DBclose(&dbh);
		}
		else
			SET_MSG_RESULT(result, zbx_strdup(NULL, get_last_odbc_strerror()));

		zbx_free(db_dsn);
		zbx_free(db_user);
		zbx_free(db_pass);
		zbx_free(db_sql);
	}
#undef DB_ODBC_SELECT_KEY

#endif	/* HAVE_ODBC */

	zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_result_string(ret));

	return ret;
}
コード例 #26
0
ファイル: pci-hotplug-old.c プロジェクト: pacificIT/qemu
static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
                                           const char *devaddr,
                                           const char *opts)
{
    PCIDevice *dev;
    DriveInfo *dinfo = NULL;
    int type = -1;
    char buf[128];
    PCIBus *root = pci_find_primary_bus();
    PCIBus *bus;
    int devfn;

    if (get_param_value(buf, sizeof(buf), "if", opts)) {
        if (!strcmp(buf, "scsi"))
            type = IF_SCSI;
        else if (!strcmp(buf, "virtio")) {
            type = IF_VIRTIO;
        } else {
            monitor_printf(mon, "type %s not a hotpluggable PCI device.\n", buf);
            return NULL;
        }
    } else {
        monitor_printf(mon, "no if= specified\n");
        return NULL;
    }

    if (get_param_value(buf, sizeof(buf), "file", opts)) {
        dinfo = add_init_drive(opts);
        if (!dinfo)
            return NULL;
        if (dinfo->devaddr) {
            monitor_printf(mon, "Parameter addr not supported\n");
            return NULL;
        }
    } else {
        dinfo = NULL;
    }

    if (!root) {
        monitor_printf(mon, "no primary PCI bus (if there are multiple"
                       " PCI roots, you must use device_add instead)");
        return NULL;
    }
    bus = pci_get_bus_devfn(&devfn, root, devaddr);
    if (!bus) {
        monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
        return NULL;
    }
    if (!qbus_is_hotpluggable(BUS(bus))) {
        monitor_printf(mon, "PCI bus doesn't support hotplug\n");
        return NULL;
    }

    switch (type) {
    case IF_SCSI:
        dev = pci_create(bus, devfn, "lsi53c895a");
        if (qdev_init(&dev->qdev) < 0)
            dev = NULL;
        if (dev && dinfo) {
            if (scsi_hot_add(mon, &dev->qdev, dinfo, 0) != 0) {
                qdev_unplug(&dev->qdev, NULL);
                dev = NULL;
            }
        }
        break;
    case IF_VIRTIO:
        if (!dinfo) {
            monitor_printf(mon, "virtio requires a backing file/device.\n");
            return NULL;
        }
        dev = pci_create(bus, devfn, "virtio-blk-pci");
        if (qdev_prop_set_drive(&dev->qdev, "drive",
                                blk_by_legacy_dinfo(dinfo)) < 0) {
            object_unparent(OBJECT(dev));
            dev = NULL;
            break;
        }
        if (qdev_init(&dev->qdev) < 0)
            dev = NULL;
        break;
    default:
        dev = NULL;
    }
    return dev;
}
コード例 #27
0
ファイル: ts3.c プロジェクト: multiplay/qstat
query_status_t
send_ts3_single_server_packet(struct qserver *server)
{
	char buf[256], *password, *username;
	int serverport;

	switch (server->challenge) {
	case 0:
		// Not seen a challenge yet, wait for it
		server->n_servers = 999;
		return (INPROGRESS);

	case 1:
		// Login if needed
		password = get_param_value(server, "password", "");
		if (0 != strlen(password)) {
			username = get_param_value(server, "username", "serveradmin");
			sprintf(buf, "login %s %s\015\012", username, password);
			break;
		}
		// NOTE: no break so we fall through
		server->challenge++;

	case 2:
		// Select port
		serverport = get_param_i_value(server, "port", 0);
		change_server_port(server, serverport, 1);
		// NOTE: we use n_servers as an indication of how many responses we are expecting to get
		if (get_player_info) {
			server->flags |= TF_PLAYER_QUERY | TF_RULES_QUERY;
			server->n_servers = 5;
		} else {
			server->flags |= TF_STATUS_QUERY;
			server->n_servers = 4;
		}
		sprintf(buf, "use port=%d\015\012", serverport);
		break;

	case 3:
		// Server Info
		sprintf(buf, "serverinfo\015\012");
		break;

	case 4:
		// Player Info, Quit or Done
		sprintf(buf, (get_player_info) ? "clientlist\015\012" : "quit\015\012");
		break;

	case 5:
		// Quit or Done
		if (get_player_info) {
			sprintf(buf, "quit\015\012");
		} else {
			return (DONE_FORCE);
		}
		break;
	}
	server->saved_data.pkt_max = -1;

	return (send_packet(server, buf, strlen(buf)));
}
コード例 #28
0
ファイル: pci-hotplug.c プロジェクト: CrazyXen/XEN_CODE
static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
                                           const char *devaddr,
                                           const char *opts)
{
    PCIDevice *dev;
    DriveInfo *dinfo = NULL;
    int type = -1;
    char buf[128];
    PCIBus *bus;
    int devfn;

    if (get_param_value(buf, sizeof(buf), "if", opts)) {
        if (!strcmp(buf, "scsi"))
            type = IF_SCSI;
        else if (!strcmp(buf, "virtio")) {
            type = IF_VIRTIO;
        } else {
            monitor_printf(mon, "type %s not a hotpluggable PCI device.\n", buf);
            return NULL;
        }
    } else {
        monitor_printf(mon, "no if= specified\n");
        return NULL;
    }

    if (get_param_value(buf, sizeof(buf), "file", opts)) {
        dinfo = add_init_drive(opts);
        if (!dinfo)
            return NULL;
        if (dinfo->devaddr) {
            monitor_printf(mon, "Parameter addr not supported\n");
            return NULL;
        }
    } else {
        dinfo = NULL;
    }

    bus = pci_get_bus_devfn(&devfn, devaddr);
    if (!bus) {
        monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
        return NULL;
    }
    if (!((BusState*)bus)->allow_hotplug) {
        monitor_printf(mon, "PCI bus doesn't support hotplug\n");
        return NULL;
    }

    switch (type) {
    case IF_SCSI:
        dev = pci_create(bus, devfn, "lsi53c895a");
        if (qdev_init(&dev->qdev) < 0)
            dev = NULL;
        if (dev && dinfo) {
            if (scsi_hot_add(mon, &dev->qdev, dinfo, 0) != 0) {
                qdev_unplug(&dev->qdev, NULL);
                dev = NULL;
            }
        }
        break;
    case IF_VIRTIO:
        if (!dinfo) {
            monitor_printf(mon, "virtio requires a backing file/device.\n");
            return NULL;
        }
        dev = pci_create(bus, devfn, "virtio-blk-pci");
        if (qdev_prop_set_drive(&dev->qdev, "drive", dinfo->bdrv) < 0) {
            qdev_free(&dev->qdev);
            dev = NULL;
            break;
        }
        if (qdev_init(&dev->qdev) < 0)
            dev = NULL;
        break;
    default:
        dev = NULL;
    }
    return dev;
}
コード例 #29
0
static void param_show_info(void)
{
	signed int value = 0;
	signed char str_val[512];

	klogi("-----------------------------------------------------");
	klogi("	Information of Parameters");
	klogi("-----------------------------------------------------");
	klogi("  - param_magic  : 0x%x", param_status.param_magic);
	klogi("  - param_version  : 0x%x", param_status.param_version);
	get_param_value(__SERIAL_SPEED, &value);
	klogi("  - 00. SERIAL_SPEED  : %d", value);
	get_param_value(__LOAD_TESTKERNEL, &value);
	klogi("  - 01. LOAD_TESTKERNEL  : %d", value);
	get_param_value(__BOOT_DELAY, &value);
	klogi("  - 02. BOOT_DELAY  : %d", value);
	get_param_value(__LCD_LEVEL, &value);
	klogi("  - 03. LCD_LEVEL  : %d", value);
	get_param_value(__SWITCH_SEL, &value);
	klogi("  - 04. SWITCH_SEL  : %d", value);
	get_param_value(__PHONE_DEBUG_ON, &value);
	klogi("  - 05. PHONE_DEBUG_ON  : %d", value);
	get_param_value(__LCD_DIM_LEVEL, &value);
	klogi("  - 06. LCD_DIM_LEVEL  : %d", value);
	get_param_value(__LCD_DIM_TIME, &value);
	klogi("  - 07. LCD_DIM_TIME  : %d", value);
	get_param_value(__FORCE_PRERECOVERY, &value);
	klogi("  - 08. FORCE_PRERECOVERY  : %d", value);
	get_param_value(__REBOOT_MODE, &value);
	klogi("  - 09. REBOOT_MODE  : %d", value);
	get_param_value(__NATION_SEL, &value);
	klogi("  - 10. NATION_SEL  : %d", value);
	get_param_value(__DEBUG_LEVEL, &value);
	klogi("  - 11. DEBUG_LEVEL  : %d", value);
	get_param_value(__SET_DEFAULT_PARAM, &value);
	klogi("  - 12. SET_DEFAULT_PARAM  : %d", value);
	get_param_value(__BATT_CAPACITY, &value);
	klogi("  - 13. BATTERY_CAPACITY  : %d", value);
	get_param_value(__LOAD_KERNEL2, &value);
	klogi("  - 14. LOAD_KERNEL2  : %d", value);
	get_param_value(__FLASH_LOCK_STATUS, &value);
	klogi("  - 15. FLASH_LOCK_STATUS  : %d", value);
	get_param_value(__PARAM_INT_14, &value);
	klogi("  - 16. PARAM_INT_14  : %d", value);

	get_param_value(__VERSION, &str_val);
	klogi("  - 17. VERSION(STR)  : %s", str_val);
	get_param_value(__CMDLINE, &str_val);
	klogi("  - 18. CMDLINE(STR)  : %s", str_val);
	get_param_value(__DELTA_LOCATION, &str_val);
	klogi("  - 19. DELTA_LOCATION(STR)  : %s", str_val);
	get_param_value(__CMDLINE_MODE, &str_val);
	klogi("  - 20. CMDLINE_MODE(STR)  : %s", str_val);
	get_param_value(__PARAM_STR_4, &str_val);
	klogi("  - 21. PARAM_STR_4(STR)  : %s", str_val);
	klogi("-----------------------------------------------------");
}