Exemple #1
0
int
libcall_printf(id_item_t **args, int *rettypes, void **retvals)
{
	id_item_t *fmt;
	struct variable *vars[MAXFARGS];
	int i;

	if (*args == NULL) {
		print_warn("printf need at least 1 argument\n");
		return 1;
	}
	fmt = *args++;
	CHECK_TYPE(fmt, ID_VAR);

	for (i = 0; args[i] != NULL; i++) {
		assert(i < MAXFARGS);
		//printf can process only variables now.
		CHECK_TYPE(args[i], ID_VAR);
		vars[i] = args[i]->var;
	}

	var_print_formatted(fmt->var, vars, i);

	rettypes[0] = ID_UNKNOWN;
	retvals[0] = NULL;

	return 0;
}
Exemple #2
0
static syn_node_t *
logic_disj()
{
	syn_node_t *right, *result;

	result = logic_conj();

	if (result == NULL)
		return NULL;
	
	while (TRUE) {
		if (match(TOK_L_OR) == FALSE)
			return result;

		right = logic_conj();
		if (right == NULL) {
			nerrors++;
			print_warn("uncomplited eq expression\n");
			right = syn_node_stub_new();
		}
		result = syn_node_op_new(result, right, OP_L_OR);
	}
	return result;

}
Exemple #3
0
syn_node_t *
expr_rest(syn_node_t *left)
{
	syn_node_t *right, *result;
	int op;

	result = left;

	while(TRUE) {
		switch (current_tok) {
		case TOK_PLUS:
			op = OP_PLUS;
			break;
		case TOK_MINUS:
			op = OP_MINUS;
			break;
		default:
			return result;
		}
		tok_next();

		right = term();
		if (right == NULL) {
			nerrors++;
			print_warn("uncomplited expr expression\n");
			right = syn_node_stub_new();
		}

		result = syn_node_op_new(result, right, op);
	}
}
Exemple #4
0
static syn_node_t *
equity()
{
	syn_node_t *right, *result;
	opcode_t op;

	result = rel_op();

	if (result == NULL)
		return NULL;
	
	while (TRUE) {
		switch (current_tok) {
		case TOK_EQ:
			op = OP_EQ;
			break;
		case TOK_NEQ:
			op = OP_NEQ;
			break;
		default:
			return result;
		}
		tok_next();

		right = rel_op();
		if (right == NULL) {
			nerrors++;
			print_warn("uncomplited eq expression\n");
			right = syn_node_stub_new();
		}
		result = syn_node_op_new(result, right, op);
	}
	return result;

}
/*
 **************************************************************************
 * FunctionName: unregister_camera_sensor;
 * Description : NA;
 * Input       : NA;
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
 */
int unregister_camera_sensor(sensor_index_t sensor_index, camera_sensor *sensor)
{
	int i = 0;
	camera_sensor **sensor_array = NULL;

	print_debug("enter %s", __func__);

	if (sensor_index >= CAMERA_SENSOR_MAX) {
		print_error("register invalid sensor index [%d]", sensor_index);
		return -EINVAL;
	}
	if (sensor == NULL) {
		print_warn("unregister NULL Sensor");
		return 0;
	}

	if (CAMERA_SENSOR_PRIMARY == sensor_index)
		sensor_array = primary_sensor_array;
	else
		sensor_array = secondary_sensor_array;

	for (i = 0; i < CAMERA_SENSOR_NUM_MAX; ++i) {
		if (sensor == sensor_array[i]) {
			sensor_array[i] = NULL;
			print_info("unregister camera sensor[%d][%d] name [%s]", sensor_index, i, sensor->info.name);
		}
	}

	return 0;
}
Exemple #6
0
static void *
_gcry_secmem_malloc_internal (size_t size)
{
  memblock_t *mb;

  if (!pool_okay)
    {
      log_info (_
	("operation is not possible without initialized secure memory\n"));
      exit (2);
    }
  if (show_warning && !suspend_warning)
    {
      show_warning = 0;
      print_warn ();
    }

  /* Blocks are always a multiple of 32. */
  size = ((size + 31) / 32) * 32;

  mb = mb_get_new ((memblock_t *) pool, size);
  if (mb)
    stats_update (size, 0);

  return mb ? &mb->aligned.c : NULL;
}
Exemple #7
0
static syn_node_t *
term_rest(syn_node_t *left)
{
	syn_node_t *right, *result;
	int op;

	result = left;

	while(TRUE) {
		switch (current_tok) {
		case TOK_MUL:
			op = OP_MUL;
			break;
		case TOK_DIV:
			op = OP_DIV;
			break;
		default:
			return result;
		}
		tok_next();

		right = factor();
		if (right == NULL) {
			nerrors++;
			print_warn("uncomplited term expression\n");
			right = syn_node_stub_new();
		}

		result = syn_node_op_new(result, right, op);
	}
}
void tapp_change_to_original_console(TApplication *p)
{
/*
        signal(SIGUSR1, SIG_DFL);
        signal(SIGUSR2, SIG_DFL);
*/

	util_privilege_on(&vuid);

	int cfd = open("/dev/console", O_WRONLY);
	if (cfd < 0 && (cfd = open("/dev/console", O_RDONLY)) < 0) {
		util_privilege_off(&vuid);
                print_strerror("/dev/console");
		return;
	}

	int n = p->gOrigVirtualConsole;
	if (ioctl(cfd, VT_ACTIVATE, n) != 0) {
		util_privilege_off(&vuid);
		print_warn("can't activate VC(%d)", n);
	}

	util_privilege_off(&vuid);
	close(cfd);
}
Exemple #9
0
void *
secmem_malloc( size_t size )
{
    MEMBLOCK *mb, *mb2;
    int compressed=0;

    if( !pool_okay ) {
	log_info(
	 _("operation is not possible without initialized secure memory\n"));
	log_info(_("(you may have used the wrong program for this task)\n"));
	exit(2);
    }
    if( show_warning && !suspend_warning ) {
	show_warning = 0;
	print_warn();
    }

    /* Blocks are always a multiple of 32.  Note that we allocate an
       extra of the size of an entire MEMBLOCK.  This is required
       becuase we do not only need the SIZE info but also extra space
       to chain up unused memory blocks.  */
    size += sizeof(MEMBLOCK);
    size = ((size + 31) / 32) * 32;

  retry:
    /* try to get it from the used blocks */
    for(mb = unused_blocks,mb2=NULL; mb; mb2=mb, mb = mb->u.next )
	if( mb->size >= size ) {
	    if( mb2 )
		mb2->u.next = mb->u.next;
	    else
		unused_blocks = mb->u.next;
	    goto leave;
	}
    /* allocate a new block */
    if( (poollen + size <= poolsize) ) {
	mb = (void*)((char*)pool + poollen);
	poollen += size;
	mb->size = size;
    }
    else if( !compressed ) {
	compressed=1;
	compress_pool();
	goto retry;
    }
    else
	return NULL;

  leave:
    cur_alloced += mb->size;
    cur_blocks++;
    if( cur_alloced > max_alloced )
	max_alloced = cur_alloced;
    if( cur_blocks > max_blocks )
	max_blocks = cur_blocks;

    return &mb->u.aligned.c;
}
/*
 **************************************************************************
 * FunctionName: add_to_queue
 * Description : add buffer to the corresponding queue;
 * Input       : f: buffer pointer;
 *               l: list head that buffer 'f' need to be added;
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
 */
inline void add_to_queue(camera_frame_buf *f, struct list_head *l, u32 flag)
{
	if (!(f->flags & flag)) {
		list_add_tail(&f->queue, l);
		f->flags |= flag;
	} else {
		print_warn("frame[%08x] has been added to queue with flag[%d]", f->phyaddr, flag);
	}
}
/*
 **************************************************************************
 * FunctionName: del_from_queue;
 * Description : Remove buffer from the corresponding queue: ready queue,
 *               work queue and done queue;
 * Input       : f: buffer pointer;
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
 */
inline void del_from_queue(camera_frame_buf *f, u32 flag)
{
	if (f->flags & flag) {
		list_del(&f->queue);
		f->flags &= (~flag);
	} else {
		print_warn("frame[%08x] NOT in queue with flag[%d]", f->phyaddr, flag);
	}
}
Exemple #12
0
static syn_node_t *
factor()
{
	syn_node_t *stat;
	
	if (match(TOK_ID)) {
		
		return 	identifier();
	
	} else if (match(TOK_NUM)) {
		
		return syn_node_num_new(lex_item_prev.num);

	}  else if (match(TOK_LPAR)) {
		stat = statesment();
		
		if (match(TOK_RPAR) == FALSE) {
			print_warn("right parenthesis missed\n");
			nerrors++;
			return stat;
		}
		
		return stat;

	} else if (current_tok == TOK_EOL) {
		
		return NULL;

	} else if (current_tok == TOK_EOF) {
		syntax_is_eof = 1;
		return NULL;
	}

	nerrors++;
	print_warn("unsupported token tryed to factor\n");
	tok_next();
	
	stat = syn_node_stub_new();

	return stat;
}
Exemple #13
0
int
libcall_arr_min_max(id_item_t **args, int *rettypes, void **retvals)
{
	arr_item_t *aitem;
	arr_iterate_t *iter;
	arr_t *arr;
	id_item_t *arg1;
	struct variable *tmp;
	struct variable *min, *max;

	assert(args != NULL && args[0] != NULL);

	DEBUG(LOG_DEFAULT, "arr_min_max executed\n");

	arg1 = args[0];

	CHECK_TYPE(arg1, ID_ARR);

	arr = arg1->arr;

	if (arr->nitems == 0) {
		print_warn("array is empty\n");
		return 1;
	}

	min = xmalloc(sizeof(*min));
	max = xmalloc(sizeof(*max));
	var_initv(min, max, NULL);

	iter = array_iterate_new(arr);

	array_iterate(iter, &aitem);
	var_copy(min, aitem->var);
	var_copy(max, aitem->var);

	while (array_iterate(iter, &aitem)) {
		tmp = aitem->var;
		if (varop_cmp(min, tmp) == -1)
			var_copy(min, tmp);
		if (varop_cmp(max, tmp) == 1)
			var_copy(max, tmp);
	}

	array_iterate_free(iter);

	rettypes[0] = ID_VAR;
	rettypes[1] = ID_VAR;
	retvals[0] = min;
	retvals[1] = max;

	return 0;
}
Exemple #14
0
void
secmem_set_flags( unsigned flags )
{
    int was_susp = suspend_warning;

    no_warning = flags & 1;
    suspend_warning = flags & 2;

    /* and now issue the warning if it is not longer suspended */
    if( was_susp && !suspend_warning && show_warning ) {
	show_warning = 0;
	print_warn();
    }
}
Exemple #15
0
//FIXME: REWRITEME!
//
static syn_node_t *
statesment()
{
	syn_node_t *right, *result;

	result = logic_disj();

	if (result == NULL)
		return NULL;
	
	if (match(TOK_AS) == FALSE)
		return result;
	

	//ASSIGNMENT
	
	//array
	if (match(TOK_LBRACE)) {
		right = array_init();
		
		if (match(TOK_RBRACE) == FALSE) {
			print_warn("right bracket missed\n");
			nerrors++;
		}

		return syn_node_as_new(result, right);
	}

	right = statesment();
	if (right == NULL) {
		nerrors++;
		print_warn("uncomplited as expression\n");
		right = syn_node_stub_new();
	}

	return syn_node_as_new(result, right);
}
/*
 **************************************************************************
 * FunctionName: imx219_liteon_start_preview;
 * Description : download preview seq for sensor preview;
 * Input       : NA;
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
*/
static int imx219_liteon_stream_on(camera_state state)
{
	int  ret = 0;

	print_debug("Enter Function:%s  , preview frmsize index=%d",
        __func__, imx219_liteon_sensor.preview_frmsize_index);

	imx219_liteon_config_dphy_clk(state);

	ret = imx219_liteon_framesize_switch(state);
	if (ret != 0)
	{
        print_warn("%s,imx219_liteon_framesize_switch fail.ret=%d.",__func__,ret);
        return ret;
	}

	return 0;
}
/*
 **************************************************************************
 * FunctionName: scharger_flash_module_init;
 * Description : NA;
 * Input       : NA;
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
*/
static int __init scharger_flash_module_init(void)
{

	scharger_flash_set_default();
	register_camera_flash(&scharger_flash_intf);
	sema_init(&busy_lock, 1);
	sema_init(&switch_lock, 1);
	if(register_torch_led(&scharger_led))
	{
		print_error( "%s:Unable to create interface\n", __func__);
		return -ENOMEM;
    }

	if(mmi_register_torch_led(mmi_scharger_led_torch_mode_set_brightness, NULL))
	{
		print_warn( "%s:Unable to create mmi_register_torch_led", __func__);
	}
	return 0;
}
/*
 **************************************************************************
 * FunctionName: hi843s_ofilm_start_preview;
 * Description : download preview seq for sensor preview;
 * Input       : NA;
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
*/
static int hi843s_ofilm_stream_on(camera_state state)
{
    int ret = 0;

    print_info("Enter Function:%s  , preview frmsize index=%d",
            __func__, hi843s_ofilm_sensor.preview_frmsize_index);

    hi843s_ofilm_config_dphy_clk(state);

    ret = hi843s_ofilm_framesize_switch(state);
    print_info("Enter Function:%s  , state=%d",__func__, state);
    if (ret != 0)
    {
        print_warn("%s,hi843s_ofilm_framesize_switch fail.ret=%d.",__func__,ret);
        return ret;
    }

    return 0;
}
Exemple #19
0
void
_gcry_secmem_set_flags (unsigned flags)
{
  int was_susp;

  SECMEM_LOCK;

  was_susp = suspend_warning;
  no_warning = flags & GCRY_SECMEM_FLAG_NO_WARNING;
  suspend_warning = flags & GCRY_SECMEM_FLAG_SUSPEND_WARNING;

  /* and now issue the warning if it is not longer suspended */
  if (was_susp && !suspend_warning && show_warning)
    {
      show_warning = 0;
      print_warn ();
    }

  SECMEM_UNLOCK;
}
Exemple #20
0
static syn_node_t *
array_init()
{
	syn_node_t *item, **arr;

	int i, len, sz;
	
	arr = NULL;
	len = sz = 0;

	do {
		item = logic_disj();
		if (item == NULL) {
			nerrors++;
			print_warn("uncomplited tuple\n");
			goto error;
		}
		if (len >= sz) {
			syn_node_t **tmp;

			sz += 4 * sizeof (*arr);

			tmp = realloc(arr, sz);
			if (tmp == NULL)
				print_warn_and_die("realloc_err\n");
			arr = tmp;
		}
		
		arr[len++] = item;

	} while (match(TOK_COMMA) != FALSE);

	return syn_node_arr_new(arr, len);

error:
	for (i = 0; i < len; i++)
		syn_node_unref(arr[i]);
	
	free(arr);
	return syn_node_stub_new();
}
/*
 **************************************************************************
 * FunctionName: register_camera_sensor;
 * Description : NA;
 * Input       : NA;
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
 */
int register_camera_sensor(sensor_index_t sensor_index, camera_sensor *sensor)
{
	int i = 0;
	camera_sensor **sensor_array = NULL;
	print_debug("enter %s", __func__);

	if (sensor_index >= CAMERA_SENSOR_MAX) {
		print_error("register invalid sensor index [%d]", sensor_index);
		return -EINVAL;
	}
	if (NULL == sensor) {
		print_error("register NULL sensor pointer");
		return -EINVAL;
	}

	if (CAMERA_SENSOR_PRIMARY == sensor_index)
		sensor_array = primary_sensor_array;
	else
		sensor_array = secondary_sensor_array;

	for (i = 0; i < CAMERA_SENSOR_NUM_MAX; i++) {
		if (sensor_array[i] == NULL)
			break;
		if (0 == strcmp(sensor_array[i]->info.name, sensor->info.name)) {
			print_warn("sensor [%s] already registered", sensor->info.name);
			return 0;
		}
	}

	if (i >= CAMERA_SENSOR_NUM_MAX) {
		print_error("%s too many sensors", __func__);
	} else {
		sensor_array[i] = sensor;
	}

	print_info("register sensor [%s] with type [%d] to [%d]", sensor->info.name, sensor_index, i);

	return 0;
}
Exemple #22
0
static ret_t
hash_ctx_table_insert(struct hash_ctx *item)
{
	int res;

	assert(item != NULL);

	if (ctx_table->count + 1 > MAX_N_CTX) {
		print_warn("to many ctx created, limit %d\n", MAX_N_CTX);
		return ret_err;
	}

	res = hash_table_insert_unique(ctx_table->hash, item->name, item);
	if (res == ret_out_of_memory)
		error(1, "error at func table insertion\n");
	else if (res == ret_entry_exists)
		error(1, "internal error, entry exists\n");

	ctx_table->count++;

	return ret_ok;
}
Exemple #23
0
static syn_node_t *
rel_op()
{
	syn_node_t *right, *result;
	int op;

	result = expr();

	if (result == NULL)
		return NULL;
	
	while (TRUE) {
		switch (current_tok) {
		case TOK_GR:
			op = OP_GR;
			break;
		case TOK_GE:
			op = OP_GE;
			break;
		case TOK_LO:
			op = OP_LO;
			break;
		case TOK_LE:
			op = OP_LE;
			break;
		default:
			return result;
		}
		tok_next();

		right = expr();
		if (right == NULL) {
			nerrors++;
			print_warn("uncomplited rel expression\n");
			right = syn_node_stub_new();
		}
		result = syn_node_op_new(result, right, op);
	}
}
Exemple #24
0
static void *
_gcry_secmem_malloc_internal (size_t size)
{
  memblock_t *mb;

  if (!pool_okay)
    {
      /* Try to initialize the pool if the user forgot about it.  */
      secmem_init (STANDARD_POOL_SIZE);
      if (!pool_okay)
        {
          log_info (_("operation is not possible without "
                      "initialized secure memory\n"));
          gpg_err_set_errno (ENOMEM);
          return NULL;
        }
    }
  if (not_locked && fips_mode ())
    {
      log_info (_("secure memory pool is not locked while in FIPS mode\n"));
      gpg_err_set_errno (ENOMEM);
      return NULL;
    }
  if (show_warning && !suspend_warning)
    {
      show_warning = 0;
      print_warn ();
    }

  /* Blocks are always a multiple of 32. */
  size = ((size + 31) / 32) * 32;

  mb = mb_get_new ((memblock_t *) pool, size);
  if (mb)
    stats_update (size, 0);

  return mb ? &mb->aligned.c : NULL;
}
void
pgAddDeviceNCheck(Circuit *ckt, Branches *pdev)
{
	Branches *daux, *pdaux;
	if(!ckt->theDeviceList)
		ckt->theDeviceList    = pdev;
	else{
		daux = pdaux = ckt->theDeviceList;
		while(daux)
		{
			if(!strcmp(daux->name,pdev->name))
			{    
				sprintf(buf,"Duplicated name: %s ignored.\n",
						pdev->name);
				print_warn(buf);
				return;
			}
			pdaux = daux;
			daux = daux->next;
		}
		pdaux->next = pdev;
	}
}
Exemple #26
0
int
libcall_sum(id_item_t **args, int *rettypes, void **retvals)
{
	id_item_t *arg;
	struct variable *res;

	assert(args != NULL);

	rettypes[0] = ID_UNKNOWN;
	retvals[0] = NULL;

	res = xmalloc(sizeof(*res));
	var_init(res);
	var_set_zero(res);

	while (*args != NULL) {
		arg = *args;
		if (arg->type != ID_VAR) {
			print_warn("error: %s ID_VAR\n",
			id_type_2_str(ID_VAR));
			goto err;
		}

		if (varop_add(res, res, arg->var) != 0)
			goto err;
		args++;
	}

	rettypes[0] = ID_VAR;
	retvals[0] = res;

	return 0;
err:
	var_clear(res);
	return 1;
}
/*
 **************************************************************************
 * FunctionName: ispv1_io_config_lane_clk;
 * Description : ispio & csi deinit;
 * Input       : NA
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
 */
 int ispv1_io_config_lane_clk(csi_index_t index, csi_lane_t mipi_lane_count, u8 lane_clk)
 {
	u8 __iomem * reg_base;
	u8 value = 0;
	u8 settle_time = 0, camera_source = 0;
	u32 phy_state1 = 0;

	char *filename = "/data/isptest/phyconfignew.txt";
	int ret;
	ret = ispv1_load_phy_setting(filename, &settle_time , &camera_source);
	if(0 != ret){
		settle_time = lane_clk;
		camera_source = 1;
	}
 	if (index == CSI_INDEX_0) {
 		reg_base = ispv1_io.csi0_base;
 	}else{
 		reg_base = ispv1_io.csi1_base; 	
 	}
	phy_state1 = CSI_GETREG32(reg_base + CSI_REG_PHY_STATE);

	if (0 == (phy_state1 & PHY_STATE_STOPSTATE0)
	    && 0 == (phy_state1 & PHY_STATE_STOPSTATECLK)) {
		print_warn("ispv1_io_config_lane_clk Not all data and clock lanes of the D-PHY are in Stop State, "
			"phy_state1 : %#x ", phy_state1);

		//return -EINVAL;			
	}

	print_info("ispv1_io_config_lane_clk phy_state1 = %#x", phy_state1);
	
	CSI_SETPHYREG8(reg_base, 0x10, settle_time);
	CSI_GETPHYREG8(reg_base, 0x10, value);
	
	print_info("reg 0x10 = %d", value);

	CSI_SETPHYREG8(reg_base, 0x11, camera_source);
	CSI_GETPHYREG8(reg_base, 0x11, value);

	print_info("reg 0x11 = %d", value);

	CSI_SETPHYREG8(reg_base, 0x20, settle_time);
	CSI_GETPHYREG8(reg_base, 0x20, value);

	print_info("reg 0x20 = %d", value);

	CSI_SETPHYREG8(reg_base, 0x21, camera_source);
	CSI_GETPHYREG8(reg_base, 0x21, value);

	print_info("reg 0x21 = %d", value);

	CSI_SETPHYREG8(reg_base, 0x30, settle_time);
	CSI_GETPHYREG8(reg_base, 0x30, value);

	print_info("reg 0x30 = %d", value);

	CSI_SETPHYREG8(reg_base, 0x31, camera_source);
	CSI_GETPHYREG8(reg_base, 0x31, value);

	print_info("reg 0x31 = %d", value);

	CSI_SETPHYREG8(reg_base, 0x40, settle_time);
	CSI_GETPHYREG8(reg_base, 0x40, value);

	print_info("reg 0x40 = %d", value);

	CSI_SETPHYREG8(reg_base, 0x41, camera_source);
	CSI_GETPHYREG8(reg_base, 0x41, value);

	print_info("reg 0x41 = %d", value);

 	return 0;
 }