예제 #1
0
int dru_get_version_change(int argc, char * argv[])
{
	char type[16];

	memset(type, 0, 16);
	if(get_device_type()==DEVICE_TYPE_MAIN){
		memcpy(type, "MU", 2);
	}else if(get_device_type()==DEVICE_TYPE_EXPEND){
		memcpy(type, "EU", 2);
	}else if(get_device_type()==DEVICE_TYPE_RAU){
		memcpy(type, "RU", 2);
	}else{
		memcpy(type, "NULL", 2);
	}
	msg_tmp.mtype = MSG_FUN_RESULT;	
	if(argc != 1){
		printf("input para cnt is not 1.\r\n");
		sprintf(msg_tmp.mtext, "input para cnt is not 1.\r\n");
		msg_send(TASK2_MODULE, (char *)&msg_tmp, strlen(msg_tmp.mtext));
		return 1;
	}
	sprintf(msg_tmp.mtext, "%s-%s-%s.%s.%s%s\r\n", type, g_type_ver, g_comm_ver, g_drv_ver, g_comm_test_ver, g_test_ver);
	msg_send(TASK2_MODULE, (char *)&msg_tmp, strlen(msg_tmp.mtext));
	return 0;
}
예제 #2
0
int download_fpga(void)
{
	if(get_device_type()==DEVICE_TYPE_MAIN){
		dru_fpga_download(FPGA_FILE_LENGTH,"/ramDisk/fpga_main.rbf");//1357101
	}else if(get_device_type()==DEVICE_TYPE_RAU){
		dru_fpga_download(FPGA_FILE_LENGTH,"/ramDisk/fpga_rrs.rbf");//1357101
	}else if(get_device_type()==DEVICE_TYPE_EXPEND){
		dru_fpga_download(FPGA_FILE_LENGTH,"/ramDisk/fpga_exp.rbf");//1357101
	}
}
예제 #3
0
/******************************************************************************
 * Routine: try_unlock_sram()
 * Description: If chip is GP/EMU(special) type, unlock the SRAM for
 *              general use.
 *****************************************************************************/
void try_unlock_memory()
{
	int mode;
	int in_sdram = is_running_in_sdram();

	/*
	 * if GP device unlock device SRAM for general use
	 * secure code breaks for Secure/Emulation device - HS/E/T
	 */
	mode = get_device_type();
	if (mode == GP_DEVICE)
		secure_unlock_mem();

	/*
	 * If device is EMU and boot is XIP external booting
	 * Unlock firewalls and disable L2 and put chip
	 * out of secure world
	 *
	 * Assuming memories are unlocked by the demon who put us in SDRAM
	 */
	if ((mode <= EMU_DEVICE) && (get_boot_type() == 0x1F)
	    && (!in_sdram)) {
		secure_unlock_mem();
		secureworld_exit();
	}

	return;
}
예제 #4
0
파일: network.c 프로젝트: TLoebner/apbteam
/* This function intializes network parameters */
void network_init(uint16_t uid)
{	
	uprintf("\r\n##########################################\r\n");
	uprintf("Network init called with UID = %d\r\n",uid);
	
	deviceType = get_device_type(uid);
	
	if(deviceType == DEVICE_TYPE_COORDINATOR)
	{
		uprintf("I'm a Cooridinator\r\n");
	}
	if(deviceType == DEVICE_TYPE_ROUTER)
	{
		uprintf("I'm a Router\r\n");
	}
	
	bool rx_on_idle = true;
	CS_WriteParameter(CS_RX_ON_WHEN_IDLE_ID, &rx_on_idle);

	/*False = random ID */
	/* True = static short address */
	bool unique_addr = true;
	CS_WriteParameter(CS_NWK_UNIQUE_ADDR_ID,&unique_addr);
	
	ExtAddr_t ownExtAddr = 0x1LL;
	CS_WriteParameter(CS_UID_ID, &ownExtAddr);

  	
  	CS_WriteParameter(CS_NWK_ADDR_ID, &uid);
	
	// Set the deviceType value to Config Server	
	CS_WriteParameter(CS_DEVICE_TYPE_ID, &deviceType);

	network_set_state(APP_NETWORK_JOIN_REQUEST);
}
예제 #5
0
int cleanup_before_linux(void)
{
	unsigned int i;

	/*
	 * this function is called just before we call linux
	 * it prepares the processor for linux
	 *
	 * we turn off caches etc ...
	 */
	disable_interrupts();

	/* turn off I/D-cache */
	icache_disable();
	dcache_disable();

	/* invalidate I-cache */
	cache_flush();

#ifndef CONFIG_L2_OFF
	/* turn off L2 cache */
	l2_cache_disable();
	/* invalidate L2 cache also */
	v7_flush_dcache_all(get_device_type());
#endif
	i = 0;
	/* mem barrier to sync up things */
	asm("mcr p15, 0, %0, c7, c10, 4": :"r"(i));

#ifndef CONFIG_L2_OFF
	l2_cache_enable();
#endif

	return 0;
}
예제 #6
0
파일: evm.c 프로젝트: frawang/u-boot
int board_late_init(void)
{
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
	char *name = "unknown";

	if (is_dra72x()) {
		if (board_is_dra72x_revc_or_later())
			name = "dra72x-revc";
		else if (board_is_dra71x_evm())
			name = "dra71x";
		else
			name = "dra72x";
	} else {
		name = "dra7xx";
	}

	set_board_info_env(name);

	/*
	 * Default FIT boot on HS devices. Non FIT images are not allowed
	 * on HS devices.
	 */
	if (get_device_type() == HS_DEVICE)
		env_set("boot_fit", "1");

	omap_die_id_serial();
	omap_set_fastboot_vars();
#endif
	return 0;
}
예제 #7
0
/*!
 * @brief Validates that the PPD is a supported device
 *
 * The event handler for this state will be called after a delay to ensure that
 * the output of the USB transceiver has stabilized.  If the D+ line is low, the
 * accessory is a valid phone-powered accessory, so the state is changed to the
 * Connecting State: PPD validate state to identify the accessory.  If the D+ line
 * is high, the accessory is invalid, so the state is changed to the Connected
 * State indicating the invalid accessory.  As a separate verification step, the
 * event handler will also verify that the accessory still appears to be a
 * phone-powered accessory (as opposed to a self-powered accessory).  If the
 * accessory does not appear to be a phone-powered accessory, the state is reset
 * to the Connecting: debounce_dev_type state to attempt to re-debounce the
 * insertion of the accessory.
 *
 * @param polling_interval a return parameter that holds the "polling rate"
 *
 * @return next_state tells the state machine what the next EMU state is
 */
EMU_STATE_T ppd_validate_handler(int *polling_interval)
{
    if (get_device_type() != EMU_DEV_TYPE_PPD)
    {
        tracemsg(_k_d("EMU: ppd_validate_handler: device_type changed! next_state = EMU_STATE_CONNECTING__DEBOUNCE_DEV_TYPE"));
        
        /* Something changed, debounce the device type again */
        *polling_interval = EMU_POLL_CONTINUE;
        
        return EMU_STATE_CONNECTING__DEBOUNCE_DEV_TYPE;
    }

    if (!get_bus_state(EMU_BUS_SIGNAL_DPLUS))
    {
        tracemsg(_k_d("EMU: ppd_validate_handler: D+ is low, next_state = EMU_STATE_CONNECTING__PPD_IDENTIFY"));
        
        /* If D+ is low and the device type has not changed
           go on to the next layer of PPD detection */
        *polling_interval = EMU_POLL_CONTINUE;
        
        return EMU_STATE_CONNECTING__PRE_PPD_IDENTIFY;
    }

    tracemsg(_k_d("EMU: ppd_validate_handler : D+ is high, current_device = MOTO_ACCY_TYPE_INVALID, next_state = EMU_STATE_CONNECTED__INVALID"));
    
    /* D+ is not low at this point so the device is invalid */
    emu_current_device = MOTO_ACCY_TYPE_INVALID;

    *polling_interval = EMU_POLL_CONTINUE;
    
    return EMU_STATE_CONNECTED__INVALID;
}
예제 #8
0
/******************************************************************************
 * Routine: s_init
 * Description: Does early system init of muxing and clocks.
 *              - Called path is with SRAM stack.
 *****************************************************************************/
void s_init(void)
{
    int in_sdram = is_running_in_sdram();

    watchdog_init();

    try_unlock_memory();

    /*
     * Right now flushing at low MPU speed.
     * Need to move after clock init
     */
    invalidate_dcache(get_device_type());

#ifdef CONFIG_L2_OFF
    l2_cache_disable();
#else
    l2_cache_enable();
#endif
    /*
     * Writing to AuxCR in U-boot using SMI for GP DEV
     * Currently SMI in Kernel on ES2 devices seems to have an issue
     * Once that is resolved, we can postpone this config to kernel
     */
    if (get_device_type() == GP_DEVICE)
        setup_auxcr();

    set_muxconf_regs();
    sdelay(100);

    prcm_init();

    per_clocks_enable();

#ifdef CONFIG_USB_EHCI_OMAP
    ehci_clocks_enable();
#endif

#ifdef CONFIG_SPL_BUILD
    preloader_console_init();

    timer_init();
#endif

    if (!in_sdram)
        mem_init();
}
예제 #9
0
static int _software_init(void)
{
	printf("software_init pthread not declare.\r\n");
	_Omc_Thread_Init();
	if(get_device_type()== DEVICE_TYPE_RAU){
		ru_para_init();
	}
	return 0;
}
예제 #10
0
/**********************************************************
 * Routine: try_unlock_sram()
 * Description: If chip is GP type, unlock the SRAM for
 *  general use.
 ***********************************************************/
void try_unlock_sram(void)
{
	/* if GP device unlock device SRAM for general use */
	if (get_device_type() == GP_DEVICE) {
		__raw_writel(0xFF, A_REQINFOPERM0);
		__raw_writel(0xCFDE, A_READPERM0);
		__raw_writel(0xCFDE, A_WRITEPERM0);
	}
}
예제 #11
0
static void find_best_workgroup(int jtrUniqDevNo) {
        size_t 		 _lws=0;
	cl_device_type 	 dTyp;
	cl_command_queue cmdq;
	cl_int 		 err;
	cl_uint 	 *dcc_hash_host
		       = (cl_uint*)mem_alloc(4 * sizeof(cl_uint) * ((MAX_KEYS_PER_CRYPT < 65536) ? MAX_KEYS_PER_CRYPT : 65536));
	cl_uint 	 *dcc2_hash_host
		       = (cl_uint*)mem_alloc(4 * sizeof(cl_uint) * ((MAX_KEYS_PER_CRYPT < 65536) ? MAX_KEYS_PER_CRYPT : 65536));
	cl_uint salt_api[9], length = 10;

	event_ctr = 0;

	//HANDLE_CLERROR(clGetDeviceInfo(devices[jtrUniqDevNo], CL_DEVICE_TYPE, sizeof(cl_device_type), &dTyp, NULL), "Failed Device Info");
	dTyp = get_device_type(jtrUniqDevNo);
	if (dTyp == CL_DEVICE_TYPE_CPU)
		globalObj[jtrUniqDevNo].lws = 1;
	else
		globalObj[jtrUniqDevNo].lws = 16;

	///Set Dummy DCC hash , unicode salt and ascii salt(username) length
	memset(dcc_hash_host, 0xb5, 4 * sizeof(cl_uint) * ((MAX_KEYS_PER_CRYPT < 65536) ? MAX_KEYS_PER_CRYPT : 65536));
	memset(salt_api, 0xfe, 9 * sizeof(cl_uint));

	cmdq = clCreateCommandQueue(context[jtrUniqDevNo], devices[jtrUniqDevNo], CL_QUEUE_PROFILING_ENABLE, &err);
	HANDLE_CLERROR(err, "Error creating command queue");

	PROFILE = 1;
	kernelExecTimeNs = CL_ULONG_MAX;

	///Find best local work size
	while (1) {
		_lws = globalObj[jtrUniqDevNo].lws;
		if (dTyp == CL_DEVICE_TYPE_CPU) {
			exec_pbkdf2(dcc_hash_host, salt_api, length, dcc2_hash_host, 4096, jtrUniqDevNo, cmdq);
			globalObj[jtrUniqDevNo].exec_time_inv = globalObj[jtrUniqDevNo].exec_time_inv / 16;
		}
		else {
			exec_pbkdf2(dcc_hash_host, salt_api, length, dcc2_hash_host, ((MAX_KEYS_PER_CRYPT < 65536) ? MAX_KEYS_PER_CRYPT : 65536), jtrUniqDevNo, cmdq);
			globalObj[jtrUniqDevNo].exec_time_inv *= ((MAX_KEYS_PER_CRYPT < 65536) ? MAX_KEYS_PER_CRYPT : 65536) / 65536;
		}

		if (globalObj[jtrUniqDevNo].lws <= _lws) break;
	}

	PROFILE = 0;

	if (options.verbosity > 2) {
		fprintf(stderr, "Optimal Work Group Size:%d\n", (int)globalObj[jtrUniqDevNo].lws);
		fprintf(stderr, "Kernel Execution Speed (Higher is better):%Lf\n", globalObj[jtrUniqDevNo].exec_time_inv);
	}

	MEM_FREE(dcc_hash_host);
	MEM_FREE(dcc2_hash_host);
	HANDLE_CLERROR(clReleaseCommandQueue(cmdq), "Release Command Queue:Failed");
}
예제 #12
0
int dru_lmx2531_gsm_init(void)
{
	if(get_device_type()==DEVICE_TYPE_MAIN){
		//dru_lmx2531_gsm_init_m();
		dru_lmx2531_gsm_main_dcs_init();
	}else{
		//dru_lmx2531_gsm_init_s();
		dru_lmx2531_gsm_slave_dcs_init();
	}
}
예제 #13
0
static gboolean
initialize_opencl (UfoResourcesPrivate *priv,
                   GError **error)
{
    cl_int errcode = CL_SUCCESS;
    cl_device_type device_type;
    cl_command_queue_properties queue_properties = CL_QUEUE_PROFILING_ENABLE;

    priv->platform = get_preferably_gpu_based_platform ();
    // add_vendor_to_build_opts (priv->build_opts, priv->platform);
    device_type = get_device_type (priv);

    // errcode = clGetDeviceIDs (priv->platform, device_type, 0, NULL, &priv->n_devices);
    errcode = clGetDeviceIDs (priv->platform, CL_DEVICE_TYPE_GPU, 0, NULL, &priv->n_devices);
    UFO_RESOURCES_CHECK_AND_SET (errcode, error);

    if (errcode != CL_SUCCESS)
        return FALSE;

    priv->devices = g_malloc0 (priv->n_devices * sizeof (cl_device_id));

//    errcode = clGetDeviceIDs (priv->platform, device_type, priv->n_devices, priv->devices, NULL);
    errcode = clGetDeviceIDs (priv->platform, CL_DEVICE_TYPE_GPU, priv->n_devices, priv->devices, NULL);
    UFO_RESOURCES_CHECK_AND_SET (errcode, error);

    if (errcode != CL_SUCCESS)
        return FALSE;

    restrict_to_gpu_subset (priv);

    priv->context = clCreateContext (NULL,
                                     priv->n_devices, priv->devices,
                                     NULL, NULL, &errcode);

    UFO_RESOURCES_CHECK_AND_SET (errcode, error);

    if (errcode != CL_SUCCESS)
        return FALSE;

    priv->command_queues = g_malloc0 (priv->n_devices * sizeof (cl_command_queue));

    for (guint i = 0; i < priv->n_devices; i++) {
        priv->command_queues[i] = clCreateCommandQueue (priv->context,
                                                        priv->devices[i],
                                                        queue_properties, &errcode);
        UFO_RESOURCES_CHECK_AND_SET (errcode, error);

        if (errcode != CL_SUCCESS)
            return FALSE;
    }

    print_used_device_overview (priv);

    return TRUE;
}
예제 #14
0
파일: control.c 프로젝트: zdimension/CEmu
/* Read from the 0x0XXX range of ports */
static uint8_t control_read(const uint16_t pio, bool peek) {
    uint8_t index = (uint8_t)pio;

    uint8_t value;
    (void)peek;

    switch (index) {
        case 0x02:
            value = control.readBatteryStatus;
            break;
        case 0x03:
            value = get_device_type();
            break;
        case 0x06:
            value = control.protectedPortsUnlocked;
            break;
        case 0x08:
            value = 0x7F;
            break;
        case 0x0B:
            /* bit 1 set if charging */
            value = control.ports[index] | (control.batteryCharging == true) << 1;
            break;
        case 0x0F:
            value = control.ports[index];
            if (control.usbBusPowered)    { value |= 0x80; }
            if (control.usbSelfPowered) { value |= 0x40; }
            break;
        case 0x1C:
            value = 0x80;
            break;
        case 0x1D: case 0x1E: case 0x1F:
            value = read8(control.privileged, (index - 0x1D) << 3);
            break;
        case 0x20: case 0x21: case 0x22:
            value = read8(control.protectedStart, (index - 0x20) << 3);
            break;
        case 0x23: case 0x24: case 0x25:
            value = read8(control.protectedEnd, (index - 0x23) << 3);
            break;
        case 0x28:
            value = control.flashUnlocked;
            break;
        case 0x3A: case 0x3B: case 0x3C:
            value = read8(control.stackLimit, (index - 0x3A) << 3);
            break;
        case 0x3D:
            value = control.protectionStatus;
            break;
        default:
            value = control.ports[index];
            break;
    }
    return value;
}
예제 #15
0
/**********************************************************
 * Routine: s_init
 * Description: Does early system init of muxing and clocks.
 * - Called path is with SRAM stack.
 **********************************************************/
void s_init(void)
{
	int i;
	int external_boot = 0;
	int in_sdram = running_in_sdram();

	watchdog_init();

	external_boot = (get_boot_type() == 0x1F) ? 1 : 0;
	/* Right now flushing at low MPU speed. Need to move after clock init */
	v7_flush_dcache_all(get_device_type(), external_boot);

	try_unlock_memory();

	if (cpu_is_3410()) {
		/* Lock down 6-ways in L2 cache so that effective size of L2 is 64K */
		__asm__ __volatile__("mov %0, #0xFC":"=r" (i));
		__asm__ __volatile__("mcr p15, 1, %0, c9, c0, 0":"=r" (i));
	}

#ifndef CONFIG_ICACHE_OFF
	icache_enable();
#endif

#ifdef CONFIG_L2_OFF
	l2cache_disable();
#else
	l2cache_enable();
#endif
	set_muxconf_regs();
	delay(100);
	
	/* Writing to AuxCR in U-boot using SMI for GP/EMU DEV */
	/* Currently SMI in Kernel on ES2 devices seems to have an isse
	 * Once that is resolved, we can postpone this config to kernel
	 */
	setup_auxcr(get_device_type(), external_boot);

	prcm_init();

	per_clocks_enable();
}
예제 #16
0
const char *get_device_type_str(cl_device_id device) {
    cl_device_type type = get_device_type(device);
    switch (type) {
        case (CL_DEVICE_TYPE_GPU):
            return "GPU";
        case (CL_DEVICE_TYPE_CPU):
            return "CPU";
        default:
            fprintf(stderr, "Unsupported device type %d\n", (int)type);
            exit(1);
    }
}
예제 #17
0
/**********************************************************
 * Routine: try_unlock_sram()
 * Description: If chip is GP type, unlock the SRAM for
 *  general use.
 ***********************************************************/
void try_unlock_sram(void)
{
	int mode;

	/* if GP device unlock device SRAM for general use */
	/* secure code breaks for Secure/Emulation device - HS/E/T*/
	mode = get_device_type();
	if (mode == GP_DEVICE) {
		secure_unlock();
	}
	return;
}
예제 #18
0
/******************************************************************************
 * Routine: s_init
 * Description: Does early system init of muxing and clocks.
 *              - Called path is with SRAM stack.
 *****************************************************************************/
void s_init(void)
{
	int in_sdram = is_running_in_sdram();

	watchdog_init();

	try_unlock_memory();

	/*
	 * Right now flushing at low MPU speed.
	 * Need to move after clock init
	 */
	v7_flush_dcache_all(get_device_type());
#ifndef CONFIG_ICACHE_OFF
	icache_enable();
#endif

#ifdef CONFIG_L2_OFF
	l2cache_disable();
#else
	l2cache_enable();
#endif
	/*
	 * Writing to AuxCR in U-boot using SMI for GP DEV
	 * Currently SMI in Kernel on ES2 devices seems to have an issue
	 * Once that is resolved, we can postpone this config to kernel
	 */
	if (get_device_type() == GP_DEVICE)
		setup_auxcr();

	set_muxconf_regs();
	delay(100);

	prcm_init();

	per_clocks_enable();

	if (!in_sdram)
		sdrc_init();
}
예제 #19
0
파일: cpu.c 프로젝트: Grommerin/uboot-imx
int cleanup_before_linux(void)
{
	unsigned int i;

#ifdef CONFIG_CMD_IMX_DOWNLOAD_MODE
	extern void clear_mfgmode_mem(void);

	clear_mfgmode_mem();
#endif

#ifdef CONFIG_VIDEO_MX5
	ipu_disable_channel(MEM_BG_SYNC);
	ipu_uninit_channel(MEM_BG_SYNC);
#endif

	/*
	 * this function is called just before we call linux
	 * it prepares the processor for linux
	 *
	 * we turn off caches etc ...
	 */
	disable_interrupts();

	/* flush cache */
	cache_flush();

	/* turn off I/D-cache */
	icache_disable();
	/* invalidate D-cache */
	dcache_disable();

#ifndef CONFIG_L2_OFF
	/* turn off L2 cache */
	l2_cache_disable();
	/* invalidate L2 cache also */
	v7_flush_dcache_all(get_device_type());
#endif
	i = 0;
	/* mem barrier to sync up things */
	asm("mcr p15, 0, %0, c7, c10, 4": :"r"(i));

	/* turn off MMU */
	MMU_OFF();

#ifndef CONFIG_L2_OFF
	l2_cache_enable();
#endif

	return 0;
}
예제 #20
0
static void ft_hs_fixups(void *fdt, bd_t *bd)
{
	/* Check we are running on an HS/EMU device type */
	if (GP_DEVICE != get_device_type()) {
		if ((ft_hs_fixup_crossbar(fdt, bd) == 0) &&
		    (ft_hs_disable_rng(fdt, bd) == 0) &&
		    (ft_hs_fixup_sram(fdt, bd) == 0))
			return;
	} else {
		printf("ERROR: Incorrect device type (GP) detected!");
	}
	/* Fixup failed or wrong device type */
	hang();
}
예제 #21
0
int board_late_init(void)
{
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
	set_board_info_env(NULL);

	/*
	 * Default FIT boot on HS devices. Non FIT images are not allowed
	 * on HS devices.
	 */
	if (get_device_type() == HS_DEVICE)
		env_set("boot_fit", "1");
#endif
	return 0;
}
예제 #22
0
파일: evm.c 프로젝트: Noltari/u-boot
int board_late_init(void)
{
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
	char *name = "unknown";

	if (is_dra72x()) {
		if (board_is_dra72x_revc_or_later())
			name = "dra72x-revc";
		else if (board_is_dra71x_evm())
			name = "dra71x";
		else
			name = "dra72x";
	} else if (is_dra76x_abz()) {
		name = "dra76x_abz";
	} else if (is_dra76x_acd()) {
		name = "dra76x_acd";
	} else {
		name = "dra7xx";
	}

	set_board_info_env(name);

	/*
	 * Default FIT boot on HS devices. Non FIT images are not allowed
	 * on HS devices.
	 */
	if (get_device_type() == HS_DEVICE)
		env_set("boot_fit", "1");

	omap_die_id_serial();
	omap_set_fastboot_vars();

	/*
	 * Hook the LDO1 regulator to EN pin. This applies only to LP8733
	 * Rest all regulators are hooked to EN Pin at reset.
	 */
	if (board_is_dra71x_evm())
		palmas_i2c_write_u8(LP873X_I2C_SLAVE_ADDR, 0x9, 0x7);
#endif
#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
	if (device_okay("/ocp/omap_dwc3_1@48880000"))
		enable_usb_clocks(0);
	if (device_okay("/ocp/omap_dwc3_2@488c0000"))
		enable_usb_clocks(1);
#endif
	return 0;
}
static unsigned int quick_bechmark(int jtrUniqDevNo) {
        cl_device_type 	 dTyp;
	cl_command_queue cmdq;
	cl_int 		 err;
	cl_uint 	 *dcc_hash_host
		       = (cl_uint*)mem_alloc(4 * sizeof(cl_uint) * 4096);
	cl_uint 	 *dcc2_hash_host
		       = (cl_uint*)mem_alloc(4 * sizeof(cl_uint) * 4096);
	cl_uint		*hmac_sha1_out
		       = (cl_uint*)mem_alloc(5 * sizeof(cl_uint) * 4096);
	cl_uint salt_api[9], length = 10;

	event_ctr = 0;

	//HANDLE_CLERROR(clGetDeviceInfo(devices[jtrUniqDevNo], CL_DEVICE_TYPE, sizeof(cl_device_type), &dTyp, NULL), "Failed Device Info");
	dTyp = get_device_type(jtrUniqDevNo);
	if (dTyp == CL_DEVICE_TYPE_CPU)
		globalObj[jtrUniqDevNo].lws = 1;
	else
		globalObj[jtrUniqDevNo].lws = 64;

	///Set Dummy DCC hash , unicode salt and ascii salt(username) length
	memset(dcc_hash_host, 0xb5, 4 * sizeof(cl_uint) * 4096);
	memset(salt_api, 0xfe, 9 * sizeof(cl_uint));

	cmdq = clCreateCommandQueue(context[jtrUniqDevNo], devices[jtrUniqDevNo], CL_QUEUE_PROFILING_ENABLE, &err);
	HANDLE_CLERROR(err, "Error creating command queue");

	PROFILE = 1;
	kernelExecTimeNs = CL_ULONG_MAX;

	exec_pbkdf2(dcc_hash_host, salt_api, length, 2048, dcc2_hash_host, 4096, jtrUniqDevNo, cmdq, hmac_sha1_out);

	PROFILE = 0;

	if (globalObj[jtrUniqDevNo].exec_time_inv < 15)
		return 4;
	else if (globalObj[jtrUniqDevNo].exec_time_inv < 25)
		return 2;
	else
		return 1;

	MEM_FREE(dcc_hash_host);
	MEM_FREE(dcc2_hash_host);
	MEM_FREE(hmac_sha1_out);
	HANDLE_CLERROR(clReleaseCommandQueue(cmdq), "Release Command Queue:Failed");
}
예제 #24
0
static Sint32
scan_cdrom_devices()
{
	SRB_HAInquiry	srb;
	int				adapter;
	int				target;
	int				lun;
	BOOL			bATAPI;
	int				nDevice;

	nDevice = 0;

	for (adapter = 0; adapter < _nAdapters; adapter++)
	{
		ZeroMemory(&srb, sizeof(srb));
		srb.SRB_Cmd   = SC_HA_INQUIRY;
		srb.SRB_Flags = 0;
		srb.SRB_HaId  = (BYTE)adapter;

		if (_pfnSendASPI32Command(&srb) != SS_COMP)
			return FALSE;

		for (target = 0; target < 8; target++)
		{
			if (target == srb.HA_SCSI_ID)
				continue;

			for (lun = 0; lun < 8; lun++)
			{
				if (get_device_type(adapter, target, lun, &bATAPI) != DTYPE_CDROM)
					continue;

				_CdromInfo[nDevice].adapter = adapter;
				_CdromInfo[nDevice].target  = target;
				_CdromInfo[nDevice].lun     = lun;
				_CdromInfo[nDevice].bATAPI  = bATAPI;
				++nDevice;
			}
		}
	}

	return nDevice;
}
예제 #25
0
int board_late_init(void)
{
	setup_board_eeprom_env();
	u8 val;

	/*
	 * DEV_CTRL.DEV_ON = 1 please - else palmas switches off in 8 seconds
	 * This is the POWERHOLD-in-Low behavior.
	 */
	palmas_i2c_write_u8(TPS65903X_CHIP_P1, 0xA0, 0x1);

	/*
	 * Default FIT boot on HS devices. Non FIT images are not allowed
	 * on HS devices.
	 */
	if (get_device_type() == HS_DEVICE)
		env_set("boot_fit", "1");

	/*
	 * Set the GPIO7 Pad to POWERHOLD. This has higher priority
	 * over DEV_CTRL.DEV_ON bit. This can be reset in case of
	 * PMIC Power off. So to be on the safer side set it back
	 * to POWERHOLD mode irrespective of the current state.
	 */
	palmas_i2c_read_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
			   &val);
	val = val | TPS65903X_PAD2_POWERHOLD_MASK;
	palmas_i2c_write_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
			    val);

	omap_die_id_serial();
	omap_set_fastboot_vars();

	am57x_idk_lcd_detect();

#if !defined(CONFIG_SPL_BUILD)
	board_ti_set_ethaddr(2);
#endif

	return 0;
}
예제 #26
0
파일: control.c 프로젝트: MaxLeiter/CEmu
/* Read from the 0x0XXX range of ports */
static uint8_t control_read(const uint16_t pio) {
    uint8_t index = pio & 0x7F;

    uint8_t value;

    switch (index) {
        case 0x01:
            value = control.cpuSpeed;
            break;
        case 0x02:
            /* Set bit 1 to set battery state */
            value = control.readBatteryStatus;
            break;
        case 0x03:
            value = get_device_type();
            break;
        case 0x0B:
            /* bit 2 set if charging */
            value = control.ports[index] | (control.batteryCharging == true)<<1;
            break;
        case 0x0F:
            value = control.ports[index];
            if(control.USBConnected)    { value |= 0x80; }
            if(control.noPlugAInserted) { value |= 0x40; }
            break;
        case 0x1D:
        case 0x1E:
        case 0x1F:
            value = read8(control.privileged, (index - 0x1D) << 3);
            break;
        case 0x28:
            value = control.ports[index] | 0x08;
            break;
        default:
            value = control.ports[index];
            break;
    }
    return value;
}
예제 #27
0
파일: main.c 프로젝트: jamesbjackson/src
/*
 * Parse a device string into type, unit, slice and partition numbers. A
 * returned value of -1 for type indicates a search should be done for the
 * first loadable device, otherwise a returned value of -1 for unit
 * indicates a search should be done for the first loadable device of the
 * given type.
 *
 * The returned values for slice and partition are interpreted by
 * disk_open().
 *
 * Valid device strings:                     For device types:
 *
 * <type_name>                               DEV_TYP_STOR, DEV_TYP_NET
 * <type_name><unit>                         DEV_TYP_STOR, DEV_TYP_NET
 * <type_name><unit>:                        DEV_TYP_STOR, DEV_TYP_NET
 * <type_name><unit>:<slice>                 DEV_TYP_STOR
 * <type_name><unit>:<slice>.                DEV_TYP_STOR
 * <type_name><unit>:<slice>.<partition>     DEV_TYP_STOR
 *
 * For valid type names, see the device_types array, above.
 *
 * Slice numbers are 1-based.  0 is a wildcard.
 */
static void
get_load_device(int *type, int *unit, int *slice, int *partition)
{
	char *devstr;
	const char *p;
	char *endp;

	*type = -1;
	*unit = -1;
	*slice = 0;
	*partition = -1;

	devstr = ub_env_get("loaderdev");
	if (devstr == NULL) {
		printf("U-Boot env: loaderdev not set, will probe all devices.\n");
		return;
	}
	printf("U-Boot env: loaderdev='%s'\n", devstr);

	p = get_device_type(devstr, type);

	/* Ignore optional spaces after the device name. */
	while (*p == ' ')
		p++;

	/* Unknown device name, or a known name without unit number.  */
	if ((*type == -1) || (*p == '\0')) {
		return;
	}

	/* Malformed unit number. */
	if (!isdigit(*p)) {
		*type = -1;
		return;
	}

	/* Guaranteed to extract a number from the string, as *p is a digit. */
	*unit = strtol(p, &endp, 10);
	p = endp;

	/* Known device name with unit number and nothing else. */
	if (*p == '\0') {
		return;
	}

	/* Device string is malformed beyond unit number. */
	if (*p != ':') {
		*type = -1;
		*unit = -1;
		return;
	}

	p++;

	/* No slice and partition specification. */
	if ('\0' == *p )
		return;

	/* Only DEV_TYP_STOR devices can have a slice specification. */
	if (!(*type & DEV_TYP_STOR)) {
		*type = -1;
		*unit = -1;
		return;
	}

	*slice = strtoul(p, &endp, 10);

	/* Malformed slice number. */
	if (p == endp) {
		*type = -1;
		*unit = -1;
		*slice = 0;
		return;
	}

	p = endp;
	
	/* No partition specification. */
	if (*p == '\0')
		return;

	/* Device string is malformed beyond slice number. */
	if (*p != '.') {
		*type = -1;
		*unit = -1;
		*slice = 0;
		return;
	}

	p++;

	/* No partition specification. */
	if (*p == '\0')
		return;

	*partition = strtol(p, &endp, 10);
	p = endp;

	/*  Full, valid device string. */
	if (*endp == '\0')
		return;

	/* Junk beyond partition number. */
	*type = -1;
	*unit = -1;
	*slice = 0;
	*partition = -1;
} 
예제 #28
0
int
main( int argc, char *argv[] )
{
     DFBResult              err;
     DFBSurfaceDescription  sdsc;
     DFBFontDescription     fdsc;
     const char            *fontfile = FONTDIR"/decker.ttf";
     int                    n;
     DeviceInfo            *devices = NULL;

     DFBCHECK(DirectFBInit( &argc, &argv ));

     DirectFBSetOption ("bg-none", NULL);

     /* create the super interface */
     DFBCHECK(DirectFBCreate( &dfb ));

     /* create a list of input devices */
     dfb->EnumInputDevices( dfb, enum_input_device, &devices );

     /* create an event buffer for all devices */
     DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_ALL,
                                           DFB_FALSE, &events ));

     /* set our cooperative level to DFSCL_FULLSCREEN
        for exclusive access to the primary layer */
     dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );

     /* get the primary surface, i.e. the surface of the
        primary layer we have exclusive access to */
     sdsc.flags = DSDESC_CAPS;
     sdsc.caps  = DSCAPS_PRIMARY | DSCAPS_DOUBLE;

     DFBCHECK(dfb->CreateSurface( dfb, &sdsc, &primary ));

     primary->GetSize( primary, &screen_width, &screen_height );

     mouse_x = screen_width  / 2;
     mouse_y = screen_height / 2;

     fdsc.flags = DFDESC_HEIGHT;

     fdsc.height = screen_width / 30;
     DFBCHECK(dfb->CreateFont( dfb, fontfile, &fdsc, &font_small ));

     fdsc.height = screen_width / 20;
     DFBCHECK(dfb->CreateFont( dfb, fontfile, &fdsc, &font_normal ));

     fdsc.height = screen_width / 10;
     DFBCHECK(dfb->CreateFont( dfb, fontfile, &fdsc, &font_large ));

     primary->Clear( primary, 0, 0, 0, 0 );
     primary->SetFont( primary, font_normal );
     primary->SetColor( primary, 0x60, 0x60, 0x60, 0xFF );
     primary->DrawString( primary, "Press any key to continue.", -1,
                          screen_width/2, screen_height/2, DSTF_CENTER );
     primary->Flip( primary, NULL, 0 );

     keys_image  = load_image( IMGDIR "/gnu-keys.png" );
     mouse_image = load_image( IMGDIR "/gnome-mouse.png" );

     if (events->WaitForEventWithTimeout( events, 10, 0 ) == DFB_TIMEOUT) {
          primary->Clear( primary, 0, 0, 0, 0 );
          primary->DrawString( primary, "Timed out.", -1,
                               screen_width/2, screen_height/2, DSTF_CENTER );
          primary->Flip( primary, NULL, 0 );
          primary->Clear( primary, 0, 0, 0, 0 );
          sleep( 1 );
     }
     else {
          DFBInputDeviceKeySymbol  last_symbol = DIKS_NULL;

          while (1) {
               DFBInputEvent evt;

               while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) {
                    const char *device_name;
                    DFBInputDeviceTypeFlags device_type;

                    primary->Clear( primary, 0, 0, 0, 0 );

                    device_name  = get_device_name( devices, evt.device_id );
                    device_type  = get_device_type( devices, evt.device_id );

                    show_event( device_name, device_type, &evt );

                    primary->Flip( primary, NULL, 0 );
               }

               if (evt.type == DIET_KEYRELEASE) {
                    if ((last_symbol == DIKS_ESCAPE || last_symbol == DIKS_EXIT) &&
                        (evt.key_symbol == DIKS_ESCAPE || evt.key_symbol == DIKS_EXIT))
                         break;
                    last_symbol = evt.key_symbol;
               }

               events->WaitForEvent( events );
          }
     }

     while (devices) {
          DeviceInfo *next = devices->next;

          free( devices );
          devices = next;
     }

     /* release our interfaces to shutdown DirectFB */
     if (keys_image)
          keys_image->Release( keys_image );
     if (mouse_image)
          mouse_image->Release( mouse_image );

     font_small->Release( font_small );
     font_normal->Release( font_normal );
     font_large->Release( font_large );

     primary->Release( primary );
     events->Release( events );
     dfb->Release( dfb );

     return 0;
}
예제 #29
0
파일: main.c 프로젝트: pombredanne/freebsd
/*
 * Parse a device string into type, unit, slice and partition numbers. A
 * returned value of -1 for type indicates a search should be done for the
 * first loadable device, otherwise a returned value of -1 for unit
 * indicates a search should be done for the first loadable device of the
 * given type.
 *
 * The returned values for slice and partition are interpreted by
 * disk_open().
 *
 * Valid device strings:                     For device types:
 *
 * <type_name>                               DEV_TYP_STOR, DEV_TYP_NET
 * <type_name><unit>                         DEV_TYP_STOR, DEV_TYP_NET
 * <type_name><unit>:                        DEV_TYP_STOR, DEV_TYP_NET
 * <type_name><unit>:<slice>                 DEV_TYP_STOR
 * <type_name><unit>:<slice>.                DEV_TYP_STOR
 * <type_name><unit>:<slice>.<partition>     DEV_TYP_STOR
 *
 * For valid type names, see the device_types array, above.
 *
 * Slice numbers are 1-based.  0 is a wildcard.
 */
static void
get_load_device(int *type, int *unit, int *slice, int *partition)
{
	char *devstr;
	const char *p;
	char *endp;

	devstr = ub_env_get("loaderdev");
	if (devstr == NULL)
		devstr = "";
	else
		printf("U-Boot setting: loaderdev=%s\n", devstr);

	p = get_device_type(devstr, type);

	*unit = -1;
	*slice = 0;
	*partition = -1;

	/*
	 * Empty device string, or unknown device name, or a bare, known 
	 * device name. 
	 */
	if ((*type == -1) || (*p == '\0')) {
		return;
	}

	/* Malformed unit number. */
	if (!isdigit(*p)) {
		*type = -1;
		return;
	}

	/* Guaranteed to extract a number from the string, as *p is a digit. */
	*unit = strtol(p, &endp, 10);
	p = endp;

	/* Known device name with unit number and nothing else. */
	if (*p == '\0') {
		return;
	}

	/* Device string is malformed beyond unit number. */
	if (*p != ':') {
		*type = -1;
		*unit = -1;
		return;
	}

	p++;

	/* No slice and partition specification. */
	if ('\0' == *p )
		return;

	/* Only DEV_TYP_STOR devices can have a slice specification. */
	if (!(*type & DEV_TYP_STOR)) {
		*type = -1;
		*unit = -1;
		return;
	}

	*slice = strtoul(p, &endp, 10);

	/* Malformed slice number. */
	if (p == endp) {
		*type = -1;
		*unit = -1;
		*slice = 0;
		return;
	}

	p = endp;
	
	/* No partition specification. */
	if (*p == '\0')
		return;

	/* Device string is malformed beyond slice number. */
	if (*p != '.') {
		*type = -1;
		*unit = -1;
		*slice = 0;
		return;
	}

	p++;

	/* No partition specification. */
	if (*p == '\0')
		return;

	*partition = strtol(p, &endp, 10);
	p = endp;

	/*  Full, valid device string. */
	if (*endp == '\0')
		return;

	/* Junk beyond partition number. */
	*type = -1;
	*unit = -1;
	*slice = 0;
	*partition = -1;
} 
예제 #30
0
파일: iMonitor.c 프로젝트: xzpeter/iMonitor
/* there are 2 kinds of devices to remove :
   1. the pidev->status == DEAD (which means that the module doesn't work)
   2. device file has gone (maybe the device is disconnected) 
   we have to take all these possibilities into consideration.
 */
int device_check(void)
{
	int i, j;

	/* clear all 'checked' sign */
	dev_usage_clear_before_check();

	/* update 'checked' */
	for (i = 0; i < SUPPORTED_DEVICE_PREFIX_N; i++) {
		for (j = dev_usage[i].start_num; j <= dev_usage[i].end_num; j++) {
			char dev_file[256];
			snprintf(dev_file, 256, "%s%s%d", DEV_DIR, dev_usage[i].keyword, j);
			/* check file existance */
			if (!access(dev_file, F_OK))
				dev_usage[i].checked[j] = 1;
		}
	}

	for (i = 0; i < SUPPORTED_DEVICE_PREFIX_N; i++) {
		for (j = dev_usage[i].start_num; j <= dev_usage[i].end_num; j++) {
			if (dev_usage[i].in_use[j] == 0 && dev_usage[i].checked[j] == 1) {
				/* a new device file */
				IDEV_TYPE type;
				type = get_device_type(i, j);
				dev_usage[i].type[j] = type;
				dm_log(NULL, "%s%d[%s] found.", dev_usage[i].keyword, j, 
						dev_model[type].name);
			} else if (dev_usage[i].in_use[j] == 1 
					&& dev_usage[i].checked[j] == 0) {
				int ret;
				dm_log(NULL, "%s%d removed.", dev_usage[i].keyword, j);
				/* a model in use is untached, try to unreg it */
				if ((ret = remove_untached_device(i, j)) < 0) {
					/* remove error */
					dm_log(NULL, "ERROR : removing device %s%d failed.[%d]", 
							dev_usage[i].keyword, j, ret);
				} else { /* remove ok */
					dm_log(NULL, "DETECT REMOVE device %s%d index %d.", 
							dev_usage[i].keyword, j, ret);
				}
			}
		}
	}

	/* type of new discovered devices are kept in {dev_usage[*].type} */
	for (i = 0; i < SUPPORTED_DEVICES; i++) {
		int add_device;
		IDEV_DEV_FILE dev_file;
		char dev_file_str[MAX_DEVICES_NUM_OF_SAME_PREFIX+1];
		unsigned char dev_taken[MAX_DEVICES_NUM_OF_SAME_PREFIX+1];

		bzero(dev_taken, sizeof(dev_taken));
		/* here, we statically only check dev_usage[0], whose keyword 
		   is "ttyUSB" */
		format_one_dev_file_str(dev_file_str, dev_usage[0].type, (IDEV_TYPE)i);
		add_device = (int)dev_model[i].device_file_adoptation(dev_file_str, 
				dev_taken, &dev_file);

		if (add_device == 1) {
			int ret;
			/* here is step 1 of register_device, 
			   set all taken devices to 'in_use' */
			for (j = 0; j < MAX_DEVICES_NUM_OF_SAME_PREFIX; j++)
				if (dev_taken[j])
					dev_usage[0].in_use[j] = 1;
			
			ret = register_device(dev_file.base_device, 
					&dev_file.related_device, (IDEV_TYPE)i);

			if (ret >= 0 && ret <= MAX_DEVICE_NO)
				dm_log(NULL, "ADD device(%d) %s as %s module.", 
						ret, dev_file.base_device, dev_model[i].name);
			else
				dm_log(NULL, "ERROR add device %s as %s module. ret[%d].", 
						dev_file.base_device, dev_model[i].name, ret);
		}
	}

	/* finally, let's see if there is any module delared dead */
	clear_dead_modules();

	return 0;
}