示例#1
0
Config_error::Config_error(int code, const char* description)
{
    init();
    init_core();
    m_core->m_code = code;
    (*this) << description;
}
示例#2
0
void
Config_error::ensure_space(UINT32 space)
{
    char* 	temp_str = 0;
    UINT32	new_len;

    init_core();

    if (len() + space > m_core->m_error_str_len)
    {
	if (len() + space > 
	    m_core->m_error_str_len + Config_error::DEFAULT_ERROR_STR_LEN)
	{
	    new_len = len() + space;
	}
	else
	{
	    new_len = m_core->m_error_str_len + 
		      Config_error::DEFAULT_ERROR_STR_LEN;
	}
	temp_str = new char[new_len];
	strcpy(temp_str, m_core->m_error_str);
	delete[] m_core->m_error_str;
	m_core->m_error_str = temp_str;
	m_core->m_error_str_len = new_len;
    }
}
	ThreadLocalStorage::ThreadLocalStorage()
	{
		init_core();

#ifdef WIN32
		if (instance->cl_tls_index == TLS_OUT_OF_INDEXES)
		{
			std::unique_lock<std::recursive_mutex> mutex_lock(instance->cl_tls_mutex);
			instance->cl_tls_index = TlsAlloc();
		}

		ThreadLocalStorage_Impl *tls_impl = static_cast<ThreadLocalStorage_Impl *>(TlsGetValue(instance->cl_tls_index));

		if (!tls_impl)
		{
			tls_impl = new ThreadLocalStorage_Impl;
			TlsSetValue(instance->cl_tls_index, tls_impl);
		}
		else
		{
			tls_impl->add_reference();
		}

#elif !defined(HAVE_TLS)
		if (!instance->cl_tls_index_created)
		{
			std::unique_lock<std::recursive_mutex> mutex_lock(instance->cl_tls_mutex);
			pthread_key_create(&instance->cl_tls_index, 0);
			instance->cl_tls_index_created = true;
		}

		ThreadLocalStorage_Impl *tls_impl = (ThreadLocalStorage_Impl *) pthread_getspecific(instance->cl_tls_index);

		if (!tls_impl)
		{
			tls_impl = new ThreadLocalStorage_Impl;
			pthread_setspecific(instance->cl_tls_index, tls_impl);
		}
		else
		{
			tls_impl->add_reference();
		}
#else

		if (!instance->cl_tls_impl)
		{
			instance->cl_tls_impl = new ThreadLocalStorage_Impl;
		}
		else
		{
			instance->cl_tls_impl->add_reference();
		}
#endif
	}
示例#4
0
int crypto_core(
        unsigned char *out,
  const unsigned char *in,
  const unsigned char *k,
  const unsigned char *c
)
{
  unsigned char xj[128];
  init_core(xj, c, k, in);      
  calc_rounds(xj, out, ROUNDS); 
  return 0;
}
示例#5
0
void main()
{
    __disable_interrupt();

    init_core();
    init_device();
    init_wdt();

    __enable_interrupt();

    microrl_init (pointerMicrorl, &serprintf);
    microrl_set_execute_callback (pointerMicrorl, execute);
    microrl_set_complete_callback (pointerMicrorl, complet);
    microrl_set_sigint_callback (pointerMicrorl, sigint);

    init_app_settings();

    print_revision();
    DEBUG_PRINTF("FlashMem: %s %s\n\r",
        get_family_desc_at25df(),
        get_density_desc_at25df());

    enable_default_lis3dh();
    init_tasks();
    init_reco_drift();
    init_can_j1939();

    DEBUG_PRINTF("\r\n\r\n");

    while (1) {
        if (pointerRingBuff->size(pointerRingBuff) > 0) {
            const uint8_t data = pointerRingBuff->get(pointerRingBuff);

            if (!get_proto_type()) {
                microrl_insert_char (pointerMicrorl, data);
            } else {
                sdp_insert_char(data);
            }
        }

        poll_can_msg();

        run_tasks();

        clear_wdt();
    }
}
示例#6
0
int main(void)
{
  struct io_pollfd ifd;
  struct io_pollfd *rfds;
  unsigned long len;
  char buf[4];

  check_core();

  init_core(&iop);
  test_assert(io_poll_size(&iop) == 0);
  verify(&iop);

  test_assert(pipe(pfd) != -1);
  test_assert(nonblock(pfd[1]) != -1);
  test_assert(nonblock(pfd[0]) != -1);

  /* test for readability */
  ifd.events = IO_POLL_READ;
  ifd.fd = pfd[0];
  test_assert(io_poll_add(&iop, &ifd) == 1);
  
  /* pipe gets readability */
  test_assert(write(pfd[1], "AAAA", 4) == 4);

  test_assert(io_poll_wait(&iop, 0) == 1);
  io_poll_rfds(&iop, &rfds, &len);
  test_assert(len == 1);
  test_assert(rfds[0].fd == ifd.fd);
  test_assert(io_poll_got_read(&rfds[0]) == 1);
  test_assert(read(rfds[0].fd, buf, 4) == 4);
  test_assert(bin_same(buf, "AAAA", 4) == 1);

  /* send EOF */
  test_assert(close(pfd[1]) != -1);

  test_assert(io_poll_wait(&iop, 0) == 1);
  io_poll_rfds(&iop, &rfds, &len);
  test_assert(len == 1);
  test_assert(rfds[0].fd == ifd.fd);
  test_assert(read(rfds[0].fd, buf, 4) == 0 || io_poll_got_eof(&rfds[0]) == 1);
 
  test_assert(io_poll_rm(&iop, &ifd) == 1);
  test_assert(close(pfd[0]) != -1);
  test_assert(io_poll_free(&iop));
  return 0;
}
	void ThreadLocalStorage::set_variable(const std::string &name, std::shared_ptr<ThreadLocalStorageData> ptr)
	{
		init_core();
#ifdef WIN32
		if (instance->cl_tls_index == TLS_OUT_OF_INDEXES)
			throw Exception("No ThreadLocalStorage object created for this thread.");
		ThreadLocalStorage_Impl *tls_impl = static_cast<ThreadLocalStorage_Impl *>(TlsGetValue(instance->cl_tls_index));
#elif !defined(HAVE_TLS)
		if (!instance->cl_tls_index_created)
			throw Exception("No ThreadLocalStorage object created for this thread.");
		ThreadLocalStorage_Impl *tls_impl = static_cast<ThreadLocalStorage_Impl *>(pthread_getspecific(instance->cl_tls_index));
#else
		ThreadLocalStorage_Impl *tls_impl = instance->cl_tls_impl;
#endif
		if (tls_impl == nullptr)
			throw Exception("No ThreadLocalStorage object created for this thread.");
		tls_impl->set_variable(name, ptr);
	}
示例#8
0
文件: mach1.c 项目: aquasync/mach1
int main(int argc, char *argv[])
{
	init();
	init2();
	static_context_t ctx;
	ctx.file = (char *)__FILE__;
	ctx.method = (char *)__FUNCTION__;
	ctx.line = __LINE__;
	ctx.parent = 0;
	ctx.block = 0;
	static_context_t *this_context = &ctx;
	/* awesome hardcoding work here */
	load_path = array_new();
	array_push(this_context, load_path, string_new_cstr("."));
	array_push(this_context, load_path, string_new_cstr("./mspec/lib"));
	jump_begin(JUMP_RESCUE)
		send3(Kernel, s_define_method, intern("load"), kernel_load, 1);
		send3(Kernel, s_define_method, intern("require"), kernel_require, 1);
		send3(Kernel, s_define_method, intern("eval"), kernel_eval, -1);
		Init_hash(this_context);
		Init_regexp(this_context);
		init_core(&ctx, g_main);
		if (argc > 1) {
			set_argv(this_context, argc - 2, argv + 2);
			kernel_load(this_context, g_main, string_new_cstr(argv[1]));
		}
		else {
			set_argv(this_context, 0, 0);
			simple_irb(this_context, g_main);
		}
	jump_rescue
		object_t *cls = send0(exc, s_class);
		printf("%s: %s\n", ((symbol_t *)((class_t *)cls)->name)->string, ((string_t *)((exception_t *)exc)->message)->bytes);
		array_t *array = (array_t *)((exception_t *)exc)->backtrace;
		int i;
		for (i = 0; i < array->used; i++)
			printf("\tfrom %s\n", ((string_t *)array->values[i])->bytes);
	jump_ensure
	jump_end
	exit(0);
	return 0;
}
示例#9
0
int			main(int ac, char **av)
{
  t_core		core;
  struct termios	term;
  int			ret;

  init_core(&core, &term);
  if ((core.env = env_load()) == NULL)
    my_puterr(ERR_ENV);
  core.prompt = get_prompt(&core);
  init_term(&core, ac, av);
  core_config_file(&core);
  if (core.is_tcaps)
    enable_row_mode(core.term);
  if (core.is_tcaps && !(ret = core_run_termcap(&core)))
    return (ret);
  if (!core.is_tcaps && !(ret = core_run_no_termcap(&core)))
    return (ret);
  if (core.shutdown != ERR_SD_PIPE && core.is_tcaps)
    disable_row_mode(core.term);
  core_free(&core);
  return (core.shutdown == 1 ? 0 : core.shutdown);
}
示例#10
0
/*
 * This routine does all of the common setup for invoking init; global
 * and non-global zones employ this routine for the functionality which is
 * in common.
 *
 * This program (init, presumably) must be a 32-bit process.
 */
int
start_init_common()
{
	proc_t *p = curproc;
	ASSERT_STACK_ALIGNED();
	p->p_zone->zone_proc_initpid = p->p_pid;

	p->p_cstime = p->p_stime = p->p_cutime = p->p_utime = 0;
	p->p_usrstack = (caddr_t)USRSTACK32;
	p->p_model = DATAMODEL_ILP32;
	p->p_stkprot = PROT_ZFOD & ~PROT_EXEC;
	p->p_datprot = PROT_ZFOD & ~PROT_EXEC;
	p->p_stk_ctl = INT32_MAX;

	p->p_as = as_alloc();
	p->p_as->a_proc = p;
	p->p_as->a_userlimit = (caddr_t)USERLIMIT32;
	(void) hat_setup(p->p_as->a_hat, HAT_INIT);

	init_core();

	init_mstate(curthread, LMS_SYSTEM);
	return (exec_init(p->p_zone->zone_initname, p->p_zone->zone_bootargs));
}
示例#11
0
文件: core.c 项目: dalevy/libvmi
status_t
windows_init(
    vmi_instance_t vmi)
{
    status_t status = VMI_FAILURE;
    windows_instance_t windows = NULL;
    os_interface_t os_interface = NULL;
    status_t real_kpgd_found = VMI_FAILURE;

    if (vmi->config == NULL) {
        errprint("VMI_ERROR: No config table found\n");
        return VMI_FAILURE;
    }

    if (vmi->os_data != NULL) {
        errprint("VMI_ERROR: os data already initialized, resetting\n");
    } else {
        vmi->os_data = safe_malloc(sizeof(struct windows_instance));
    }

    bzero(vmi->os_data, sizeof(struct windows_instance));
    windows = vmi->os_data;
    windows->version = VMI_OS_WINDOWS_UNKNOWN;

    g_hash_table_foreach(vmi->config, (GHFunc)windows_read_config_ghashtable_entries, vmi);

    /* Need to provide this functions so that find_page_mode will work */
    os_interface = safe_malloc(sizeof(struct os_interface));
    bzero(os_interface, sizeof(struct os_interface));
    os_interface->os_get_offset = windows_get_offset;
    os_interface->os_pid_to_pgd = windows_pid_to_pgd;
    os_interface->os_pgd_to_pid = windows_pgd_to_pid;
    os_interface->os_ksym2v = windows_kernel_symbol_to_address;
    os_interface->os_usym2rva = windows_export_to_rva;
    os_interface->os_v2sym = windows_rva_to_export;
    os_interface->os_read_unicode_struct = windows_read_unicode_struct;
    os_interface->os_teardown = windows_teardown;

    vmi->os_interface = os_interface;

    if(VMI_FAILURE == check_pdbase_offset(vmi)) {
        goto error_exit;
    }

    /* At this point we still don't have a directory table base,
     * so first we try to get it via the driver (fastest way).
     * If the driver gets us a dtb, it will be used _only_ during the init phase,
     * and will be replaced by the real kpgd later. */
    if(VMI_FAILURE == driver_get_vcpureg(vmi, &vmi->kpgd, CR3, 0)) {
        if(VMI_FAILURE == get_kpgd_method2(vmi)) {
            errprint("Could not get kpgd, will not be able to determine page mode\n");
            goto error_exit;
        } else {
            real_kpgd_found = VMI_SUCCESS;
        }
    }

    if(VMI_FAILURE == init_core(vmi)) {
        goto error_exit;
    }

    if (VMI_PM_UNKNOWN == vmi->page_mode) {
        if (VMI_FAILURE == find_page_mode(vmi)) {
            errprint("Failed to find correct page mode.\n");
            goto error_exit;
        }
    }

    if (VMI_SUCCESS == real_kpgd_found) {
        status = VMI_SUCCESS;
        goto done;
    }

    /* If we have a dtb via the driver we need to get the real kpgd */
    if (VMI_SUCCESS == get_kpgd_method0(vmi)) {
        dbprint(VMI_DEBUG_MISC, "--kpgd method0 success\n");
        status = VMI_SUCCESS;
        goto done;
    }
    if (VMI_SUCCESS == get_kpgd_method1(vmi)) {
        dbprint(VMI_DEBUG_MISC, "--kpgd method1 success\n");
        status = VMI_SUCCESS;
        goto done;
    }

    if (VMI_SUCCESS == get_kpgd_method2(vmi)) {
        dbprint(VMI_DEBUG_MISC, "--kpgd method2 success\n");
        status = VMI_SUCCESS;
        goto done;
    }

    vmi->kpgd = 0;
    errprint("Failed to find kernel page directory.\n");
    goto error_exit;

done:
    return status;

error_exit:
    windows_teardown(vmi);
    return VMI_FAILURE;
}
示例#12
0
int main(int argc, char *argv[])
{
    struct core *core;
    int option;
    bool enable_memory_dump = false;
    uint32_t mem_dump_base = 0;
    uint32_t mem_dump_length = 0;
    char *mem_dump_filename = NULL;
    size_t mem_dump_filename_len = 0;
    bool verbose = false;
    uint32_t fb_width = 640;
    uint32_t fb_height = 480;
    bool block_device_open = false;
    bool enable_fb_window = false;
    uint32_t total_threads = 4;
    char *separator;
    uint32_t memory_size = 0x1000000;
    const char *shared_memory_file = NULL;
    struct stat st;

    enum
    {
        MODE_NORMAL,
        MODE_COSIMULATION,
        MODE_GDB_REMOTE_DEBUG
    } mode = MODE_NORMAL;

    while ((option = getopt(argc, argv, "f:d:vm:b:t:c:r:s:i:o:")) != -1)
    {
        switch (option)
        {
            case 'v':
                verbose = true;
                break;

            case 'r':
                screen_refresh_rate = parse_num_arg(optarg);
                break;

            case 'f':
                enable_fb_window = true;
                separator = strchr(optarg, 'x');
                if (!separator)
                {
                    fprintf(stderr, "Invalid frame buffer size %s\n", optarg);
                    return 1;
                }

                fb_width = parse_num_arg(optarg);
                fb_height = parse_num_arg(separator + 1);
                break;

            case 'm':
                if (strcmp(optarg, "normal") == 0)
                    mode = MODE_NORMAL;
                else if (strcmp(optarg, "cosim") == 0)
                    mode = MODE_COSIMULATION;
                else if (strcmp(optarg, "gdb") == 0)
                    mode = MODE_GDB_REMOTE_DEBUG;
                else
                {
                    fprintf(stderr, "Unkown execution mode %s\n", optarg);
                    return 1;
                }

                break;

            case 'd':
                // Memory dump, of the form: filename,start,length
                separator = strchr(optarg, ',');
                if (separator == NULL)
                {
                    fprintf(stderr, "bad format for memory dump\n");
                    usage();
                    return 1;
                }

                mem_dump_filename_len = (size_t)(separator - optarg);
                mem_dump_filename = (char*) malloc(mem_dump_filename_len + 1);
                strncpy(mem_dump_filename, optarg, mem_dump_filename_len);
                mem_dump_filename[mem_dump_filename_len] = '\0';
                mem_dump_base = parse_num_arg(separator + 1);

                separator = strchr(separator + 1, ',');
                if (separator == NULL)
                {
                    fprintf(stderr, "bad format for memory dump\n");
                    usage();
                    return 1;
                }

                mem_dump_length = parse_num_arg(separator + 1);
                enable_memory_dump = true;
                break;

            case 'b':
                if (open_block_device(optarg) < 0)
                    return 1;

                block_device_open = true;
                break;

            case 'c':
                memory_size = parse_num_arg(optarg);
                break;

            case 't':
                total_threads = parse_num_arg(optarg);
                if (total_threads < 1 || total_threads > 32)
                {
                    fprintf(stderr, "Total threads must be between 1 and 32\n");
                    return 1;
                }

                break;

            case 's':
                shared_memory_file = optarg;
                break;

            case 'i':
                recv_interrupt_fd = open(optarg, O_RDWR);
                if (recv_interrupt_fd < 0)
                {
                    perror("main: failed to open receive interrupt pipe");
                    return 1;
                }

                if (fstat(recv_interrupt_fd, &st) < 0)
                {
                    perror("main: stat failed on receive interrupt pipe");
                    return 1;
                }

                if ((st.st_mode & S_IFMT) != S_IFIFO)
                {
                    fprintf(stderr, "%s is not a pipe\n", optarg);
                    return 1;
                }

                break;

            case 'o':
                send_interrupt_fd = open(optarg, O_RDWR);
                if (send_interrupt_fd < 0)
                {
                    perror("main: failed to open send interrupt pipe");
                    return 1;
                }

                if (fstat(send_interrupt_fd, &st) < 0)
                {
                    perror("main: stat failed on send interrupt pipe");
                    return 1;
                }

                if ((st.st_mode & S_IFMT) != S_IFIFO)
                {
                    fprintf(stderr, "%s is not a pipe\n", optarg);
                    return 1;
                }

                break;

            case '?':
                usage();
                return 1;
        }
    }

    if (optind == argc)
    {
        fprintf(stderr, "No image filename specified\n");
        usage();
        return 1;
    }

    // Don't randomize memory for cosimulation mode, because
    // memory is checked against the hardware model to ensure a match

    core = init_core(memory_size, total_threads, mode != MODE_COSIMULATION,
                     shared_memory_file);
    if (core == NULL)
        return 1;

    if (load_hex_file(core, argv[optind]) < 0)
    {
        fprintf(stderr, "Error reading image %s\n", argv[optind]);
        return 1;
    }

    if (enable_fb_window)
    {
        if (init_frame_buffer(fb_width, fb_height) < 0)
            return 1;
    }

    switch (mode)
    {
        case MODE_NORMAL:
            if (verbose)
                enable_tracing(core);

            set_stop_on_fault(core, false);
            if (enable_fb_window)
            {
                while (execute_instructions(core, ALL_THREADS, screen_refresh_rate))
                {
                    update_frame_buffer(core);
                    poll_fb_window_event();
                    check_interrupt_pipe(core);
                }
            }
            else
            {
                while (execute_instructions(core, ALL_THREADS, 1000000))
                    check_interrupt_pipe(core);
            }

            break;

        case MODE_COSIMULATION:
            set_stop_on_fault(core, false);
            if (run_cosimulation(core, verbose) < 0)
                return 1;	// Failed

            break;

        case MODE_GDB_REMOTE_DEBUG:
            set_stop_on_fault(core, true);
            remote_gdb_main_loop(core, enable_fb_window);
            break;
    }

    if (enable_memory_dump)
        write_memory_to_file(core, mem_dump_filename, mem_dump_base, mem_dump_length);

    dump_instruction_stats(core);
    if (block_device_open)
        close_block_device();

    if (stopped_on_fault(core))
        return 1;

    return 0;
}
示例#13
0
int main(int argc, char *argv[]){
	/*
	 * Here i need to get the TV resolution
	 */
	ecore_psl1ght_optimal_screen_resolution_get(&REAL_WIDTH, &REAL_HEIGHT);
	
	if(REAL_HEIGHT > 720){
		REAL_WIDTH  = 1280;
		REAL_HEIGHT = 720;
	}
	
	init_core(&core, REAL_WIDTH, REAL_HEIGHT, "Playstation Channel");
	edje_start();
	init_core_file();
	
	Cursor_Y[0] = 0.25972*REAL_HEIGHT;
	Cursor_Y[1] = 0.5445 *REAL_HEIGHT;
	
	Cursor_X[0] = 0.1*REAL_WIDTH;		// APPS      (APP 1) || MEDIA     (APP 4)
	Cursor_X[1] = 0.37421875*REAL_WIDTH;	// BMANAGERS (APP 2) || RETRO     (APP 5)
	Cursor_X[2] = 0.65*REAL_WIDTH;		// GAMES     (APP 3) || OPTIONS   (APP 6)


	
	load_edj_from_file(&core, &info, PSC_INFO_SCREEN_PATH, "information", REAL_WIDTH, REAL_HEIGHT);
	load_edj_from_file(&core, &menu[0], PSC_OPTION_MENU_PATH, "menu", REAL_WIDTH, REAL_HEIGHT); //OPTIONS
	load_edj_from_file(&core, &menu[1], PSC_SUB_MENU_PATH, "menu", REAL_WIDTH, REAL_HEIGHT);    //SUB MENU

	main_layer = evas_object_rectangle_add(get_main_object(&core));
	evas_object_resize(main_layer, REAL_WIDTH, REAL_HEIGHT);
	evas_object_color_set(main_layer, 0, 0, 0, 0);
	evas_object_show(main_layer);

	ecore_evas_object_associate(core.ee_core, main_layer, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
	override_text(&info, "information_download", " ");
	draw_edj(&info, 0, 0);

//-----------------------------------------------------------------------------------------------------

	dir_make(CACHE_PATH);
	if(file_exist(CACHE_PATH"/files.zip"))
		file_delete(CACHE_PATH"/files.zip");

	{
		char url[20];
		sprintf(url,"%s",MAINURL);
//		if(!ecore_file_download(url,CACHE_PATH"/files.zip", download_main_is_finished, download_main_func, NULL, NULL))
		download_file(url,CACHE_PATH"/files.zip", download_main_func_curl, download_main_is_finished);
		if(get_download_status()==DOWNLOAD_FAILED)
			goto end;
	}
	LoadStrings(PSC_MAIN_MENU_LANG_PATH, Categories_Names, 6);
	{
		string XML_files[5];
		LoadMainStringsFromXML(CACHE_PATH"/files.xml",XML_files);
		for(int i=0;i<5;i++){
			char tmp_char[250];
			sprintf(tmp_char,"%s/%s",CACHE_PATH,XML_files[i].c_str());
			LoadStringsFromXML(tmp_char,&Apps[i]);
			Applications[i].Image = new EFL_Image [Apps[i].n_elem];
			Applications[i].x = new int [Apps[i].n_elem];
			Applications[i].y = new int [Apps[i].n_elem];
			for(int j=0, k=0, h=0;j<Apps[i].n_elem;j++,(k>1) ? h=!h : h=h,(k>1) ? k=0 : k++ ){
				sprintf(tmp_char,"%s/%s",CACHE_PATH,Apps[i].img_file[j].c_str());
				create_image_obj(&core, &Applications[i].Image[j], tmp_char, REAL_WIDTH*0.25, REAL_HEIGHT*0.246);
				Applications[i].x[j] = Cursor_X[k];
				Applications[i].y[j] = Cursor_Y[h];
				draw_image(&Applications[i].Image[j], Applications[i].x[j], Applications[i].y[j]);
				hide_obj(Applications[i].Image[j].obj);
			}
		}
	}
//-----------------------------------------------------------------------------------------------------
	load_edj_from_file(&core, &menu[2], PSC_MAIN_MENU_PATH, "menu", REAL_WIDTH, REAL_HEIGHT);                                 //MAIN MENU
	load_edj_from_file(&core, &bar, PSC_MAIN_MENU_BAR_PATH, "main_menu_bar", REAL_WIDTH*0.25, REAL_HEIGHT*0.246);             //(Main/Sub) Menu bar
	load_edj_from_file(&core, &download, PSC_DOWNLOAD_MASK_PATH, "download_mask", REAL_WIDTH*0.3125, REAL_HEIGHT*0.3055);     //DOWNLOAD MENU

	override_text(&menu[2], "error_text", "");

	down = evas_object_rectangle_add(get_main_object(&core));
	evas_object_move(down, (REAL_WIDTH-(REAL_WIDTH*0.3125))/2 +REAL_WIDTH*0.03125,REAL_HEIGHT*0.08861 +(REAL_HEIGHT-(REAL_HEIGHT*0.3055))/2);
	Bar_X_Val = REAL_WIDTH*0.25;
	Bar_Y_Val = REAL_HEIGHT*0.058;
	evas_object_resize(down, 1, Bar_Y_Val);
	evas_object_color_set(down, 0, 0, 255, 255); //blue
	hide_obj(down);
	load_edj_from_file(&core, &download_perc, PSC_DOWNLOADPERC_MASK_PATH, "download_perc", REAL_WIDTH*0.3125, REAL_HEIGHT*0.3055);    //DOWNLOAD MENU
	load_edj_from_file(&core, &download_ask, PSC_DOWNLOAD_MASK_PATH, "download_mask_ask", REAL_WIDTH*0.3125, REAL_HEIGHT*0.3055);     //DOWNLOAD MENU ASK XMB

	ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, on_exit_handler, NULL);
	information_timer = ecore_timer_add(PSC_INFO_SCREEN_TIMER, delete_info, NULL);
	enable_callback(&core, main_layer, EVAS_CALLBACK_KEY_DOWN , user_menu_handler);
	
	override_text(&menu[0], "ps3_version_edit", get_ps3_version());
	char space [100];

	if(get_ps3_free_space()>1000000000)
		sprintf(space,"%ld/%ld Gigabytes",get_ps3_free_space()/1000000000,get_ps3_total_space()/1000000000);
	else if(get_ps3_free_space()>1000000)
		sprintf(space,"%ld/%ld Megabytes",get_ps3_free_space()/1000000,get_ps3_total_space()/1000000);
	else if(get_ps3_free_space()>1000)
		sprintf(space,"%ld/%ld Kilobytes",get_ps3_free_space()/1000,get_ps3_total_space()/1000);
	else
		sprintf(space,"%ld/%ld Bytes",get_ps3_free_space(),get_ps3_total_space());

	override_text(&menu[0], "ps3_hdd_free_space_edit", space);
#ifdef PSCHANNEL_VERSION
	sprintf(space,"%f",PSCHANNEL_VERSION);
	override_text(&menu[0], "software_version", space);
#else
	override_text(&menu[0], "software_version", " ");
#endif
	if(sysModuleIsLoaded(SYSMODULE_NET))
		override_text(&menu[2], "error_text", "SYSMODULE_NET NOT LOADED!!");



	start_core_loop();
	disable_callback(main_layer,EVAS_CALLBACK_KEY_DOWN, user_menu_handler);
	
end:
	dir_recursive_delete(CACHE_PATH);

	for(int i=0;i<3;i++)
		delete_edj(&menu[i]);
	for(int i=0;i<5;i++)
		for(int j=0;j<Apps[i].n_elem;j++)
			delete_obj(Applications[i].Image[j].obj);
	delete_edj(&bar);
	delete_edj(&download);
	delete_edj(&download_perc);
	delete_obj(down);


	edje_stop();
	stop_core_file();
	ecore_psl1ght_shutdown();
//	stop_core(&core);  not needed on ps3.

	if(pkg_is_installed)
		reboot_sys();
	

	return 0;
}
示例#14
0
文件: main.c 项目: jmrosinski/test
int main (int argc, char **argv)
{
  int ret;
  int c;
  int pin2core = 0;    // 1=> pin threads to single core
  int pin2range = 0;   // 1=> pin threads to range of cores
  int cpn = 1;         // default cores per node

  ret = MPI_Init (&argc, &argv);
  ret = MPI_Comm_rank (MPI_COMM_WORLD, &iam);
  shiftiam = iam;
  ret = MPI_Comm_size (MPI_COMM_WORLD, &nranks);

  pid = getpid ();
  nthreads = omp_get_max_threads ();
  core   = malloc (nthreads * sizeof (int));
  status = malloc (nthreads * sizeof (char));
  tidarr = malloc (nthreads * sizeof (int));
  fp     = malloc (nthreads * sizeof (FILE *));
  init_core (nthreads);

  while ((c = getopt (argc, argv, "hcrn:w:")) != -1) {
    switch (c) {
    case 'h':
      if (iam == 0) {
	printf ("Usage: %s [-c] to pin to single core\n"
		"          [-r] to pin to range of cores\n"
		"          [-n <num>] number of cores per node\n"
		"          [-w <num> number of seconds between forced shifts", argv[0]);
      }
      return 0;
      break;
    case 'c':
      pin2core = 1;
      break;
    case 'r':
      pin2range = 1;
      break;
    case 'n':
      cpn = atoi (optarg);
      break;
    case 'w':
      shiftintvl = atoi (optarg);
      break;
    default:
      printf ("unknown option %c\n", c);
      return 1;
      break;
    }
  }

  if (pin2core) {
    if (iam == 0) {
      printf ("Pinning threads to individual cores\n");
    }
    ret = set_affinity_ (&iam, &cpn, &nthreads, &pin2core);
  } else if (pin2range) {
    if (iam == 0) {
      printf ("Pinning threads to subsetted range of cores\n");
    }
    ret = set_affinity_ (&iam, &cpn, &nthreads, &pin2core);
  } else {
    if (iam == 0) {
      printf ("No pinning\n");
    }
  }

  ret = print_affinity_ (&iam);
  fill_tid_fp ();

  while (1) {
    // Loop for some time (default 10 seconds), printing any core attachment changes
    threaded_loop ();
    // Change affinity to guarantee all is working as expected
    if (pin2core || pin2range) {
      shiftiam = (shiftiam + 1) % nranks;
      printf ("shiftiam=%d\n", shiftiam);
      ret = set_affinity_ (&shiftiam, &cpn, &nthreads, &pin2core);
    }
    ret = print_affinity_ (&iam);
    print_all_statuses ();
  }
}
示例#15
0
int main(int argc, char* argv[])
{
	init_log();

	(void)argc;
	(void)argv;
	
	// [cobralib] unmount iso / eject
	cobra_send_fake_disc_eject_event();
	cobra_umount_disc_image();

	// Check if isolist.self is launching this app... 
	FILE* fp_flag = fopen("/dev_hdd0/game/SISO00123/USRDIR/isolist_finished", "r");
	if(fp_flag) 
	{
		// load normally...
		fclose(fp_flag);
		*&fp_flag = NULL;

		// remove the launch flag...
		cellFsUnlink("/dev_hdd0/game/SISO00123/USRDIR/isolist_finished");

	} else {
		// generate ISO list...
		sys_game_process_exitspawn((char*)ISOLIST_SELF, NULL, NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
	}
	
	if(!LoadModules()) 
	{
		// error...
		(void)exit_app();
		return 0;
	}
	
	// setup sys callback
	if(cellSysutilRegisterCallback(0, callback_sysutil_exit, NULL) != CELL_OK) 
	{
		// error...
		(void)exit_app();
		return 0;
	}

	InputInit();

	if(InitPSGLVideo(device, context, screen_width, screen_height, render_width, render_height))
	{
		// clear vid on startup
		(void)render(true);
	
		// init font
		if(!font_init(render_width, render_height)) { bRun = false; }

		// init app core modules, ftp, settings, etc...
		if(!init_core()) { bRun = false; }
		
		// loop
		while(bRun)
		{
			cellSysutilCheckCallback();			

			(void)input();			
			(void)render(false);			
		}

	} else {
		// error msg here...
	}
	
	(void)exit_app();
	return 0;
}
示例#16
0
文件: main.c 项目: metredigm/hunter
int main(int argc, char** argv) {
	init_core();
	debug_message("[hunter] initialized core");

	init_graphic();
	debug_message("[hunter] initialized graphics, mode W%d H%d", window_get_width(global_get(global_get_singleton(), GLOBAL_WINDOW)), window_get_height(global_get(global_get_singleton(), GLOBAL_WINDOW)));

	init_sound();
	debug_message("[hunter] initialized sound");

	init_systems();
	debug_message("[hunter] initialized systems");

	window* window_handle = global_get(global_get_singleton(), GLOBAL_WINDOW);
	input* input_handle = global_get(global_get_singleton(), GLOBAL_INPUT);
	syscontainer* syscontainer_handle = global_get(global_get_singleton(), GLOBAL_SYSCONTAINER);
	text* text_handle = global_get(global_get_singleton(), GLOBAL_TEXT);
	hl_render* hl_render_handle = global_get(global_get_singleton(), GLOBAL_HL_RENDER);
	shader* shader_texture_handle = global_get(global_get_singleton(), GLOBAL_SHADER_TEXTURE);
	camera* camera_handle = global_get(global_get_singleton(), GLOBAL_CAMERA);
	debug_draw* debug_draw_handle = global_get(global_get_singleton(), GLOBAL_DEBUG_DRAW);

	float delta_ref_point = time_get_elapsed(window_handle);
	float delta_accumulator = 0.0f;
	float delta_frame_time = 0.0f;

	float fps_accumulator = 0.0f;
	float fps_value = 0.0f;
	float fps_value_last = fps_value;
	unsigned int fps_counter = 0;

	unsigned int game_kill_flag = 0;

	debug_message("[hunter] posting init event to systems");
	syscontainer_post_event(syscontainer_handle, EVENT_INIT);

	while (!game_kill_flag) {
		delta_frame_time = time_get_elapsed(window_handle) - delta_ref_point;
		delta_ref_point = time_get_elapsed(window_handle);

		window_update(window_handle);

		input_state current_input_state;
		input_get_input_state(input_handle, &current_input_state);

		game_kill_flag |= window_get_should_close(window_handle);
		game_kill_flag |= current_input_state.key_dev;

		window_set_clear_color(window_handle, 1.0f, 0.0f, 1.0f, 0.0f);
		debug_draw_clear(debug_draw_handle);
		window_clear(window_handle);

		delta_accumulator += delta_frame_time;

		if (delta_accumulator < 0.0f) {
			delta_accumulator = 0.0f;
		}

		while (delta_accumulator >= 1.0f / DELTA_REFERENCE_FPS) {
			syscontainer_post_event(syscontainer_handle, EVENT_PRE_LOGIC);
			syscontainer_post_event(syscontainer_handle, EVENT_LOGIC);
			syscontainer_post_event(syscontainer_handle, EVENT_POST_LOGIC);

			delta_accumulator -= 1.0f / DELTA_REFERENCE_FPS;
		}

		syscontainer_post_event(syscontainer_handle, EVENT_DRAW);

		window_set_blend_mode(window_handle, WINDOW_BLEND_ALPHA);

		debug_draw_render_all(debug_draw_handle);

		hl_render_draw(hl_render_handle, shader_texture_handle, camera_handle);
		hl_render_clear(hl_render_handle);

		fps_counter++;
		fps_accumulator += delta_frame_time;

		if (fps_accumulator >= 1.0f) {
			fps_value_last = fps_value;
			fps_value = (float) fps_counter / fps_accumulator;
			fps_counter = 0;
			fps_accumulator = 0.0f;
		}

		text_batch fps_batch = {20, 20, 0.2f, 0.8f, 1.0f, 1.0f, "", "monospace", 12};
		sprintf(fps_batch.text_data, "FPS : %3.2f (%3.2f)", fps_value, fps_value - fps_value_last);

		text_submit_batch(text_handle, &fps_batch);

		text_render_all(text_handle);
		text_flush_batch(text_handle);

		window_swap_buffers(window_handle);
	}

	debug_message("[hunter] posting destroy event to systems");
	syscontainer_post_event(syscontainer_handle, EVENT_DESTROY);

	free_systems();
	free_sound();
	free_graphic();
	free_core();

	h_free_all();

	debug_message("[hunter] terminated cleanly");
	return 0;
}
示例#17
0
文件: core.c 项目: WaitXie/libvmi
status_t
windows_init(
    vmi_instance_t vmi)
{
    status_t status = VMI_FAILURE;
    windows_instance_t windows = NULL;
    os_interface_t os_interface = NULL;

    if (vmi->config == NULL) {
        errprint("VMI_ERROR: No config table found\n");
        return VMI_FAILURE;
    }

    if (vmi->os_data != NULL) {
        errprint("VMI_ERROR: os data already initialized, resetting\n");
    } else {
        vmi->os_data = safe_malloc(sizeof(struct windows_instance));
    }

    bzero(vmi->os_data, sizeof(struct windows_instance));
    windows = vmi->os_data;
    windows->version = VMI_OS_WINDOWS_UNKNOWN;

    g_hash_table_foreach(vmi->config, (GHFunc)windows_read_config_ghashtable_entries, vmi);

    /* Need to provide this functions so that find_page_mode will work */
    os_interface = safe_malloc(sizeof(struct os_interface));
    bzero(os_interface, sizeof(struct os_interface));
    os_interface->os_get_offset = windows_get_offset;
    os_interface->os_pid_to_pgd = windows_pid_to_pgd;
    os_interface->os_pgd_to_pid = windows_pgd_to_pid;
    os_interface->os_ksym2v = windows_kernel_symbol_to_address;
    os_interface->os_usym2rva = windows_export_to_rva;
    os_interface->os_rva2sym = windows_rva_to_export;
    os_interface->os_teardown = windows_teardown;

    vmi->os_interface = os_interface;

    if(VMI_FAILURE == check_pdbase_offset(vmi)) {
        goto error_exit;
    }

    if (VMI_PM_UNKNOWN == vmi->page_mode) {
        if(VMI_FAILURE == get_kpgd_method2(vmi)) {
          errprint("Could not get kpgd, will not be able to determine page mode\n");
          goto error_exit;
        }

        if(VMI_FAILURE == init_core(vmi)) {
            goto error_exit;
        }

        if (VMI_FAILURE == find_page_mode(vmi)) {
            errprint("Failed to find correct page mode.\n");
            goto error_exit;
        }
    } else if(VMI_FAILURE == init_core(vmi)) {
        goto error_exit;
    }

    if (vmi->kpgd) {
        /* This can happen for file because find_cr3() is called and this
         * is set via get_kpgd_method2() */
        status = VMI_SUCCESS;
    } else
    if (VMI_SUCCESS == get_kpgd_method0(vmi)) {
        dbprint(VMI_DEBUG_MISC, "--kpgd method0 success\n");
        status = VMI_SUCCESS;
    } else
    if (VMI_SUCCESS == get_kpgd_method1(vmi)) {
        dbprint(VMI_DEBUG_MISC, "--kpgd method1 success\n");
        status = VMI_SUCCESS;
    } else
    if (VMI_SUCCESS == get_kpgd_method2(vmi)) {
        dbprint(VMI_DEBUG_MISC, "--kpgd method2 success\n");
        status = VMI_SUCCESS;
    } else {
        errprint("Failed to find kernel page directory.\n");
        goto error_exit;
    }

    return status;

error_exit:
    windows_teardown(vmi);
    return VMI_FAILURE;
}
示例#18
0
Config_error::Config_error(int _code)
{
    init();
    init_core();
    m_core->m_code = _code;
}
示例#19
0
/* Performs the core dump */
int do_coredump(int pid, char *core_file)
{
	int ret;

	/* Initialise members of core process */
	init_core();

	/* Getting thread information and seizing them */
	ret = seize_threads(pid);
	if (ret)
		goto cleanup;

	/* Wait for threads to stop */
	ret = wait_for_threads_to_stop();
	if (ret)
		goto cleanup;

	/* Get VMAS */
	ret = get_vmas(pid, &cp);
	if (ret)
		goto cleanup;

	/* Compat Support */
	cp.elf_class = ret = get_elf_class(pid, &cp);
	if (ret == -1)
		goto cleanup;

	/* Initialise core file name */
	cp.corefile = core_file;

	/* Do elf_dump */
	if (cp.elf_class == ELFCLASS32)
		ret = do_elf32_coredump(pid, &cp);
	else
		ret = do_elf64_coredump(pid, &cp);
	if (ret)
		goto cleanup;

cleanup:

	/* Release the threads */
	release_threads();

	if (cp.t_id)
		free(cp.t_id);

	if (cp.vmas)
		free_maps(cp.vmas);

	if (cp.elf_hdr)
		free(cp.elf_hdr);

	if (cp.notes)
		free_notes(cp.notes);

	if (cp.phdrs)
		free(cp.phdrs);

	if (cp.phdrs_count)
		free(cp.shdrs);

	errno = status;

	return ret;
}