예제 #1
0
파일: tpmain.c 프로젝트: DashW/Ingenuity
int main(int argc, char *argv[]) {
    tp_vm *tp = tp_init(argc,argv);
    /* INIT */
    tp_call(tp,"py2bc","tinypy",tp_None);
    tp_deinit(tp);
    return(0);
}
예제 #2
0
파일: main.c 프로젝트: TrickPlay/Trickplay
int main(int argc,char * argv[])
{
    signal( SIGINT , quit );

    tp_init(&argc,&argv);

    context = tp_context_new();

    if ( argc > 1 && * ( argv[ argc - 1 ] ) != '-' )
    {
        tp_context_set( context, "app_path", argv[ argc - 1  ] );
    }

    // Media player constructor

    tp_context_set_media_player_constructor(context,mp_constructor);

    // Populate a sampler info structure with the context
    // and add a notification handler

    void * sampler = 0;

    tp_context_add_notification_handler(context,TP_NOTIFICATION_RUNNING,trickplay_running,&sampler);
    tp_context_add_notification_handler(context,TP_NOTIFICATION_EXITING,trickplay_exiting,&sampler);

    // Run the context

    int result = tp_context_run(context);

    tp_context_free(context);

    context = 0;

    return result;
}
예제 #3
0
int CGCodeInterpreter::InitializeInterp(void)
{
	int status;

	Output[0]='\0';
	line_number=0;

	// initialize the trajectory planner
	tp_init();

	CoordMotion->SetTPParams();

	CoordMotion->DownloadInit();  // intialize download/look ahead variables  
	
	status = rs274ngc_init();
	if (status != RS274NGC_OK)	return rs274ErrorExit(status);

	
	if (ToolFile[0]!=0)
	{
		status = read_tool_file(ToolFile, &_setup);
		if (status != RS274NGC_OK)	return rs274ErrorExit(status);
	}

	if (SetupFile[0]!=0)
	{
		status = read_setup_file(SetupFile, &_setup);
		if (status != RS274NGC_OK)	return rs274ErrorExit(status);
	}
	CoordMotion->m_PreviouslyStopped = STOPPED_NONE;
	m_InitializeOnExecute = false;
	return 0;
}
예제 #4
0
int t1_tp_reset(struct petp *tp, struct tp_params *p, unsigned int tp_clk)
{
	adapter_t *adapter = tp->adapter;

	tp_init(adapter, p, tp_clk);
	writel(F_TP_RESET, adapter->regs +  A_TP_RESET);
	return 0;
}
예제 #5
0
파일: tp.c 프로젝트: catcher22/tarantool
static inline void
test_check_buffer_initialized(void) {
	struct tp req;
	tp_init(&req, NULL, 0, tp_realloc, NULL);
	tp_select(&req, 0, 0, 0, 0); /* could fail on assert */
	tp_tuple(&req);
	tp_sz(&req, "key");
	tp_free(&req);
}
예제 #6
0
int main(int argc, char *argv[]) {
	if(argc > 1)
	{
		tp_vm *tp = tp_init(argc,argv);
		tp_import(tp,argv[1],"__main__",0);
		tp_deinit(tp);
	}
    return(0);
}
예제 #7
0
파일: main.cpp 프로젝트: brucetsao/Print3D
int main(int argc, char *argv[])
{
	init();
	if(init_setting() != 0){
		print_errmsg("ERROR: SETTING init fail. \n");
		return 1;	
	}
	if(gc_init() != 0){
		print_errmsg("ERROR: G_CODE init fail. \n");
		return 1;
	}
	if (cm_init() == false)
	{
		print_errmsg("ERROR: USB-DEV init fail. \n");
		return 1;
	}
  
	if (cmd_init() == false)
	{
		print_errmsg("ERROR: G code init fail.\n");
		cm_close();
		return 1;
	}
	
	if (tp_init() == false)
	{
		print_errmsg("ERROR: Temperature library init fail. \n");
		cmd_close();
		cm_close();
		return 1;
	}

	plan_init();
	Config_ResetDefault();
	st_init();

	while(1) {
		LCD(10UL);
		getCommand(10UL);
		process_commands(50UL);
		stepper(1000L);
		manageHeater(10UL);
	}

	st_close();
	plan_close();
	tp_close();
	cmd_close();
	cm_close();
	//debug
	//sfp_close();
	return 0;
}
예제 #8
0
static int sunxi_ts_resume(struct platform_device *pdev)
{ 
        dprintk(DEBUG_SUSPEND_INFO, "[%s] return from standby state: %d. \n", __FUNCTION__, (int)standby_type); 

	/*process for normal standby*/
	if (NORMAL_STANDBY == standby_type) {
		 writel(STYLUS_UP_DEBOUNCE|STYLUS_UP_DEBOUCE_EN|TP_DUAL_EN|TP_MODE_EN,TP_BASSADDRESS + TP_CTRL1);
	/*process for super standby*/	
	} else if(SUPER_STANDBY == standby_type) {
		tp_init();
	}
	return 0;
}
예제 #9
0
static int
Tinypy_init(TinypyObject *self, PyObject *args, PyObject *kwds)
{
    self->vm = tp_init(0, NULL);
    double time = 5*1000;       /* 5 seconds default */
    long mem = 16*1024*1024;    /* 16 megabytes default */
    
    if (!PyArg_ParseTuple(args, "|dl", &time, &mem)) {
        return 0;
    }
    tp_sandbox(self->vm, time, mem);

    return 0;
}
예제 #10
0
int main(int argc, char **argv){
	pTp= tp_create(10, THD_NUM);
	int i;

	exit_cnt = 0;
	pthread_mutex_init(&lock, NULL);
	tp_init(pTp);
	srand((int)time(0));
	for(i=0; i < THD_NUM; i++){
		tp_process_job(pTp, proc_fun, i);
	}
	tp_run(pTp);
	free(pTp);
	fprintf(stdout, "All jobs done!\r\n");
	return 0;
}
예제 #11
0
static int
Tinypy_init(TinypyObject *self, PyObject *args, PyObject *kwds)
{
    self->vm = tp_init(0, NULL);
    double time = 5*1000;       /* 5 seconds default */
    unsigned long mem = 16*1024*1024;    /* 16 megabytes default */
    static char *kwlist[] = { "time", "mem", 0 };

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|dk",
        kwlist, &time, &mem)) {
        return -1;
    }
    tp_sandbox(self->vm, time, mem);

    return 0;
}
예제 #12
0
파일: s2.cpp 프로젝트: dCache/s2
int
main(int argc, char *argv[])
{
  int i;					/* loop counter */

  /* Initialisation */
  init_s2();

  /* Close all open diagnose streams at exit */
  atexit(exit_handler);         /* normal exit */

  /* Parse command line options */
  i = parse_cmd_opts(argc, argv);

  tp_init(opts.tp_size);

#if 0
#define MAX_REQUESTS	5
  int data[MAX_REQUESTS];
  /* run a loop that generates requests */
  for (i = 0; i < MAX_REQUESTS; i++) {
    data[i] = i;
    tp_enqueue(&data[i], NULL, NULL);
  }
#else
  int a = 1, b = 2, c = 3, d = 4;

  sleep(1);
  tp_enqueue(&a, NULL, NULL);
  tp_enqueue(&b, NULL, NULL);
  tp_enqueue(&c, NULL, NULL);
  tp_enqueue(&d, NULL, NULL);
  tp_dequeue(&c);
#endif

//  sleep(10);

  tp_cleanup();

  /* Parse and evaluate S2 language file(s) */
  if(0) s2_run(argc, argv, i);

  return 0;
}
예제 #13
0
파일: tp.c 프로젝트: catcher22/tarantool
static inline int
test_check_read(void)
{
	int fd;
	struct sockaddr_in tt;
	if ((fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
		printf("Failed to create socket\n");
		return 1;
	}

	memset(&tt, 0, sizeof(tt));
	tt.sin_family = AF_INET;
	tt.sin_addr.s_addr = inet_addr("127.0.0.1");
	tt.sin_port = htons(33013);
	if (connect(fd, (struct sockaddr *) &tt, sizeof(tt)) < 0) {
		printf("Failed to connect\n");
		return 1;
	}

	struct tp req;
	tp_init(&req, NULL, 0, tp_realloc, NULL);
	tp_insert(&req, 0, 0);
	tp_tuple(&req);
	tp_sz(&req, "_i32");
	tp_sz(&req, "0e72ae1a-d0be-4e49-aeb9-aebea074363c");
	tp_select(&req, 0, 0, 0, 1);
	tp_tuple(&req);
	tp_sz(&req, "_i32");
	int rc = write(fd, tp_buf(&req), tp_used(&req));
	if (rc != tp_used(&req))
		return 1;

	tp_free(&req);

	rc = test_check_read_reply(fd);
	if (rc != 0)
		return 1;
	rc = test_check_read_reply(fd);
	if (rc != 0)
		return 1;

	close(fd);
	return 0;
}
예제 #14
0
파일: tp.c 프로젝트: catcher22/tarantool
static inline int
test_check_read_reply(int fd) {
	struct tp rep;
	tp_init(&rep, NULL, 0, tp_realloc, NULL);
	while (1) {
		ssize_t to_read = tp_req(&rep);
		if (to_read <= 0)
			break;
		ssize_t new_size = tp_ensure(&rep, to_read);
		if (new_size == -1) {
			// no memory (?)
			return 1;
		}
		ssize_t res = read(fd, rep.p, to_read);
		if (res == 0) {
			// eof
			return 1;
		} else if (res < 0) {
			// error
			return 1;
		}
		tp_use(&rep, res);
	}

	ssize_t server_code = tp_reply(&rep);

	if (server_code != 0) {
		printf("error: %-.*s\n", tp_replyerrorlen(&rep),
		   tp_replyerror(&rep));
		tp_free(&rep);
		return 1;
	}
	if (tp_replyop(&rep) == 17) { /* select */
		reply_print(&rep);
	} else
	if (tp_replyop(&rep) == 13) { /* insert */
	} else {
		return 1;
	}
	tp_free(&rep);
	return 0;
}
예제 #15
0
파일: ps2mouse.c 프로젝트: corum/adnw
bool ps2_init_mouse(void)
{
    g_mouse_enabled = 0;
    scrollcnt = 0;

    uint8_t d[2];

    tp_reset();

    if ( ! ps2_send_expect(0xff, PS2_ACK) )
        return false;

    d[0]=read_packet(); //Bat
    d[1]=read_packet(); //dev ID

    //Enable Data reporting
    if ( ! ps2_send_expect(0xf4, PS2_ACK) )
        return false;

    //send_packet(0xe8); //Set Resolution
    //read_packet(); //Ack
    //send_packet(0x01); //8counts/mm
    //read_packet(); //Ack
    ////
    //send_packet(0xf3); //SetSample rate
    //read_packet(); //Ack
    //send_packet(0x64); //200 smaples a second

    //Set remote mode
    if( ! ps2_send_expect(0xf0, PS2_ACK) )
        return false;

    printf("\nTP init: Bat:%02x Id:%02x",d[0],d[1]);

    tp_init();

    /// @todo Set only on successful init
    g_mouse_enabled = 1;

    return true;
}
예제 #16
0
파일: taint.cpp 프로젝트: KurSh/panda
void enable_taint(){
    panda_cb pcb;
    pcb.before_block_exec = before_block_exec;
    panda_register_callback(plugin_ptr, PANDA_CB_BEFORE_BLOCK_EXEC, pcb);
    pcb.after_block_exec = after_block_exec;
    panda_register_callback(plugin_ptr, PANDA_CB_AFTER_BLOCK_EXEC, pcb);
    pcb.phys_mem_read = phys_mem_read_callback;
    panda_register_callback(plugin_ptr, PANDA_CB_PHYS_MEM_READ, pcb);
    pcb.phys_mem_write = phys_mem_write_callback;
    panda_register_callback(plugin_ptr, PANDA_CB_PHYS_MEM_WRITE, pcb);
    pcb.cb_cpu_restore_state = cb_cpu_restore_state;
    panda_register_callback(plugin_ptr, PANDA_CB_CPU_RESTORE_STATE, pcb);
    
    if (!execute_llvm){
        panda_enable_llvm();
    }
    llvm::llvm_init();
    panda_enable_llvm_helpers();

    /*
     * Run instrumentation pass over all helper functions that are now in the
     * module, and verify module.
     */
    llvm::Module *mod = tcg_llvm_ctx->getModule();
    for (llvm::Module::iterator i = mod->begin(); i != mod->end(); i++){
        if (i->isDeclaration()){
            continue;
        }
        PIFP->runOnFunction(*i);
    }
    std::string err;
    if(verifyModule(*mod, llvm::AbortProcessAction, &err)){
        printf("%s\n", err.c_str());
        exit(1);
    }

    /*
     * Taint processor initialization
     */

    //uint32_t ram_size = 536870912; // 500MB each
#ifdef TARGET_X86_64
    // this is only for the fast bitmap which we currently aren't using for
    // 64-bit, it only supports 32-bit
    //XXX FIXME
    uint64_t ram_size = 0;
#else
    uint32_t ram_size = 0xffffffff; //guest address space -- QEMU user mode
#endif
    uint64_t hd_size =  536870912;
    uint64_t io_size = 536870912;
    uint16_t num_vals = 2000; // LLVM virtual registers //XXX assert this
    shadow = tp_init(hd_size, ram_size, io_size, num_vals);
    if (shadow == NULL){
        printf("Error initializing shadow memory...\n");
        exit(1);
    }

    taintfpm = new llvm::FunctionPassManager(tcg_llvm_ctx->getModule());

    // Add the taint analysis pass to our taint pass manager
    llvm::FunctionPass *taintfp =
        llvm::createPandaTaintFunctionPass(15*1048576/* global taint op buffer
        size, 10MB */, NULL /* existing taint cache */);
    PTFP = static_cast<llvm::PandaTaintFunctionPass*>(taintfp);
    taintfpm->add(taintfp);
    taintfpm->doInitialization();

    // Populate taint cache with helper function taint ops
    for (llvm::Module::iterator i = mod->begin(); i != mod->end(); i++){
        if (i->isDeclaration()){
            continue;
        }
        PTFP->runOnFunction(*i);
    }
}
예제 #17
0
파일: taint.cpp 프로젝트: Debug-Orz/panda
void __taint_enable_taint(void) {
    if(taintEnabled) {return;}
  printf ("__taint_enable_taint\n");
  taintJustEnabled = true;
  taintEnabled = true;
    panda_cb pcb;

    pcb.before_block_exec = before_block_exec;
    panda_register_callback(plugin_ptr, PANDA_CB_BEFORE_BLOCK_EXEC, pcb);
    pcb.after_block_exec = after_block_exec;
    panda_register_callback(plugin_ptr, PANDA_CB_AFTER_BLOCK_EXEC, pcb);
    pcb.phys_mem_read = phys_mem_read_callback;
    panda_register_callback(plugin_ptr, PANDA_CB_PHYS_MEM_READ, pcb);
    pcb.phys_mem_write = phys_mem_write_callback;
    panda_register_callback(plugin_ptr, PANDA_CB_PHYS_MEM_WRITE, pcb);
    pcb.cb_cpu_restore_state = cb_cpu_restore_state;
    panda_register_callback(plugin_ptr, PANDA_CB_CPU_RESTORE_STATE, pcb);

    // for hd and network taint
#ifdef CONFIG_SOFTMMU
    pcb.replay_hd_transfer = cb_replay_hd_transfer_taint;
    panda_register_callback(plugin_ptr, PANDA_CB_REPLAY_HD_TRANSFER, pcb);
    pcb.replay_net_transfer = cb_replay_net_transfer_taint;
    panda_register_callback(plugin_ptr, PANDA_CB_REPLAY_NET_TRANSFER, pcb);
    pcb.replay_before_cpu_physical_mem_rw_ram = cb_replay_cpu_physical_mem_rw_ram;
    panda_register_callback(plugin_ptr, PANDA_CB_REPLAY_BEFORE_CPU_PHYSICAL_MEM_RW_RAM, pcb);
#endif

    panda_enable_precise_pc(); //before_block_exec requires precise_pc for panda_current_asid

    if (!execute_llvm){
        panda_enable_llvm();
    }
    llvm::llvm_init();
    panda_enable_llvm_helpers();

    /*
     * Run instrumentation pass over all helper functions that are now in the
     * module, and verify module.
     */
    llvm::Module *mod = tcg_llvm_ctx->getModule();
    for (llvm::Module::iterator i = mod->begin(); i != mod->end(); i++){
        if (i->isDeclaration()){
            continue;
        }
#if defined(TARGET_ARM)
        //TODO: Fix handling of ARM's cpu_reset() helper
        // Currently, we skip instrumenting it, because we generate invalid LLVM bitcode if we try
        std::string modname =  i->getName().str();
        if (modname == "cpu_reset_llvm"){
            printf("Skipping instrumentation of cpu_reset\n");
            continue;
        }
#endif
        PIFP->runOnFunction(*i);
    }
    std::string err;
    if(verifyModule(*mod, llvm::AbortProcessAction, &err)){
        printf("%s\n", err.c_str());
        exit(1);
    }

    /*
     * Taint processor initialization
     */

    //uint32_t ram_size = 536870912; // 500MB each
#ifdef TARGET_X86_64
    // this is only for the fast bitmap which we currently aren't using for
    // 64-bit, it only supports 32-bit
    //XXX FIXME
    uint64_t ram_size = 0;
#else
    uint32_t ram_size = 0xffffffff; //guest address space -- QEMU user mode
#endif
    uint64_t hd_size =  536870912;
    uint64_t io_size = 536870912;
    uint16_t num_vals = 2000; // LLVM virtual registers //XXX assert this
    shadow = tp_init(hd_size, ram_size, io_size, num_vals);
    if (shadow == NULL){
        printf("Error initializing shadow memory...\n");
        exit(1);
    }

    taintfpm = new llvm::FunctionPassManager(tcg_llvm_ctx->getModule());

    // Add the taint analysis pass to our taint pass manager
    llvm::FunctionPass *taintfp =
        llvm::createPandaTaintFunctionPass(15*1048576/* global taint op buffer
        size, 10MB */, NULL /* existing taint cache */);
    PTFP = static_cast<llvm::PandaTaintFunctionPass*>(taintfp);
    taintfpm->add(taintfp);
    taintfpm->doInitialization();

    // Populate taint cache with helper function taint ops
    for (llvm::Module::iterator i = mod->begin(); i != mod->end(); i++){
        if (i->isDeclaration()){
            continue;
        }
        PTFP->runOnFunction(*i);
    }
}
예제 #18
0
파일: s2.cpp 프로젝트: dCache/s2
/********************************************************************
 * Parse command-line arguments (non -+ options)
 *
 * Returns:
 *   ERR_OK: if success
 *   >= ERR_OK: otherwise
 ********************************************************************/
static int
s2_run(int argc, char **argv, int i)
{
  int rval = ERR_OK, lval;
  int i_1 = i;
  Node *root = NULL;
  Process *proc = NULL;
  BOOL tp_created = FALSE;

  /* init progress bar */
  Process::progress(-1,proc);

#if defined(HAVE_SRM21) || defined(HAVE_SRM22)
  srm_init();
#endif

  lval = parse(opts.scr_fname, &root);
  DM_DBG(DM_N(1), "parser return value=%d\n", lval);
  UPDATE_MAX(rval, lval);
  if(rval > opts.s2_eval) {
    /* stop evaluation */
    UPDATE_MAX(rval, ERR_NEXEC);
    goto cleanup;
  }

  /* create thread pool */
  if(!tp_created) tp_init(opts.tp_size);
  tp_created = TRUE;

  /* pretty-print S2 tree ($ENV{VAR} are evaluated) */
  if(opts.pp_fname) lval = pp_print(root);
  DM_DBG(DM_N(1), "pretty-printer return value=%d\n", lval);
  UPDATE_MAX(rval, lval);

  if(root) {
    Process::threads_init();
    proc = new Process(root, NULL, NULL);

    if(!proc) {
      DM_ERR(ERR_SYSTEM, _("failed to create a Process: %s\n"), _(strerror(errno)));
      UPDATE_MAX(rval, ERR_SYSTEM);
      goto cleanup;
    }

    /* write ${0}..${n} variables */
    const char *name = cmd_label();
    proc->WriteVariable("0", name, TRUE);
    for(; i < argc; i++) {
      proc->WriteVariable(i2str(i - i_1 + 1).c_str(), argv[i], TRUE);
    }

    setenv("CLIENT_INFO", build_client_info(name), 1);

    lval = proc->eval();
    Process::threads_destroy();
    DM_DBG(DM_N(1), "evaluation return value=%d\n", lval);
    UPDATE_MAX(rval, lval);
  }

  /* after-evaluation print of the tree */
  if(opts.e2_fname) lval = e2_print(root);
  DM_DBG(DM_N(2), "after-evaluation print return value=%d\n", lval);
  UPDATE_MAX(rval, lval);

cleanup:
  /* cleanup */
  DELETE(proc);	/* free proc *first*, then root */
  DELETE(root);

  /* destroy thread pool */
  if(tp_created) tp_cleanup();

  /* hide progress bar */
  Process::progress(0,proc);

  DM_DBG(DM_N(1), "s2_run return value=%d\n", rval);
  return rval;
}
예제 #19
0
파일: taint2.cpp 프로젝트: chyyuu/panda
void __taint2_enable_taint(void) {
    if(taintEnabled) {return;}
    printf ("taint2: __taint_enable_taint\n");
    taintEnabled = true;
    panda_cb pcb;

    pcb.after_block_translate = after_block_translate;
    panda_register_callback(plugin_ptr, PANDA_CB_AFTER_BLOCK_TRANSLATE, pcb);
    pcb.before_block_exec_invalidate_opt = before_block_exec_invalidate_opt;
    panda_register_callback(plugin_ptr, PANDA_CB_BEFORE_BLOCK_EXEC_INVALIDATE_OPT, pcb);
    pcb.before_block_exec = before_block_exec;
    panda_register_callback(plugin_ptr, PANDA_CB_BEFORE_BLOCK_EXEC, pcb);
    pcb.after_block_exec = after_block_exec;
    panda_register_callback(plugin_ptr, PANDA_CB_AFTER_BLOCK_EXEC, pcb);
    pcb.phys_mem_read = phys_mem_read_callback;
    panda_register_callback(plugin_ptr, PANDA_CB_PHYS_MEM_READ, pcb);
    pcb.phys_mem_write = phys_mem_write_callback;
    panda_register_callback(plugin_ptr, PANDA_CB_PHYS_MEM_WRITE, pcb);
/*
    pcb.cb_cpu_restore_state = cb_cpu_restore_state;
    panda_register_callback(plugin_ptr, PANDA_CB_CPU_RESTORE_STATE, pcb);
    // for hd and network taint
    pcb.replay_hd_transfer = cb_replay_hd_transfer_taint;
    panda_register_callback(plugin_ptr, PANDA_CB_REPLAY_HD_TRANSFER, pcb);
    pcb.replay_net_transfer = cb_replay_net_transfer_taint;
    panda_register_callback(plugin_ptr, PANDA_CB_REPLAY_NET_TRANSFER, pcb);
    pcb.replay_before_cpu_physical_mem_rw_ram = cb_replay_cpu_physical_mem_rw_ram;
    panda_register_callback(plugin_ptr, PANDA_CB_REPLAY_BEFORE_CPU_PHYSICAL_MEM_RW_RAM, pcb);
*/
    panda_enable_precise_pc(); //before_block_exec requires precise_pc for panda_current_asid

    if (!execute_llvm){
        panda_enable_llvm();
    }
    panda_enable_llvm_helpers();

    /*
     * Taint processor initialization
     */

    shadow = tp_init(TAINT_BYTE_LABEL, TAINT_GRANULARITY_BYTE);
    if (shadow == NULL){
        printf("Error initializing shadow memory...\n");
        exit(1);
    }

    // Initialize memlog.
    memset(&taint_memlog, 0, sizeof(taint_memlog));

    llvm::Module *mod = tcg_llvm_ctx->getModule();
    FPM = tcg_llvm_ctx->getFunctionPassManager();

    // Add the taint analysis pass to our taint pass manager
    PTFP = new llvm::PandaTaintFunctionPass(shadow, &taint_memlog);
    FPM->add(PTFP);

    if (optimize_llvm) {
        printf("taint2: Adding default optimizations (-O1).\n");
        llvm::PassManagerBuilder Builder;
        Builder.OptLevel = 1;
        Builder.SizeLevel = 0;
        Builder.populateFunctionPassManager(*FPM);
    }

    FPM->doInitialization();

    // Populate module with helper function taint ops
    for (auto i = mod->begin(); i != mod->end(); i++){
        if (!i->isDeclaration()) PTFP->runOnFunction(*i);
    }

    printf("taint2: Done processing helper functions for taint.\n");

    std::string err;
    if(verifyModule(*mod, llvm::AbortProcessAction, &err)){
        printf("%s\n", err.c_str());
        exit(1);
    }

    //tcg_llvm_write_module(tcg_llvm_ctx, "/tmp/llvm-mod.bc");

    printf("taint2: Done verifying module. Running...\n");
}
예제 #20
0
void cmd_tp_calibrate(uint_least16_t fgcolor, uint_least16_t bgcolor)
{
  uint_least8_t i;
  CAL_POINT lcd_points[3] = {CAL_POINT1, CAL_POINT2, CAL_POINT3}; //calibration point postions
  CAL_POINT tp_points[3];

  tp_init(); //enable/reset touch

  tp_read();
  if(tp_rawz())
  {
     lcd_clear(bgcolor);
     lcd_drawtext(10, 10, "Release Touchpanel.", 1, fgcolor, 0, 0);
     while(tp_rawz() > MIN_PRESSURE){ tp_read(); };
  }

  do
  {
    //clear screen and wait for touch release
    lcd_clear(bgcolor);
    lcd_setorientation(180);
    lcd_drawtext(LCD_CENTER, (LCD_HEIGHT/2)+10, "Calibration", 2, RGB(128,128,128), 0, 0);
    lcd_setorientation(0);
    lcd_drawtext(LCD_CENTER, (LCD_HEIGHT/2)+10, "Calibration", 2, RGB(128,128,128), 0, 0);

    for(i=0; i<3; )
    {
      //draw point
      lcd_drawcircle(lcd_points[i].x, lcd_points[i].y, 15, fgcolor);
      lcd_drawline(lcd_points[i].x-10, lcd_points[i].y,    lcd_points[i].x-3,  lcd_points[i].y,    fgcolor);
      lcd_drawline(lcd_points[i].x+3,  lcd_points[i].y,    lcd_points[i].x+10, lcd_points[i].y,    fgcolor);
      lcd_drawline(lcd_points[i].x,    lcd_points[i].y-10, lcd_points[i].x,    lcd_points[i].y-3,  fgcolor);
      lcd_drawline(lcd_points[i].x,    lcd_points[i].y+3,  lcd_points[i].x,    lcd_points[i].y+10, fgcolor);

      //touch detected? -> save point
      tp_read();
      if(tp_getz() > (MIN_PRESSURE*1.5))
      {
        //mark point
        lcd_fillcircle(lcd_points[i].x, lcd_points[i].y, 4, RGB(255,0,0));
        //wait and clear point
        delay_ms(400);
        lcd_fillcircle(lcd_points[i].x, lcd_points[i].y, 15, bgcolor);
        //save point
        tp_points[i].x = tp_rawx();
        tp_points[i].y = tp_rawy();
        i++;
        //wait till press is over
        while(tp_rawz() > MIN_PRESSURE){ tp_read(); };
      }

      //data available
      if(if_available())
      {
        if(if_read8() == 0)
        {
          i = 0xFF;
          break;
        }
      }
    }
  }
  while((i!=0xFF) && (tp_calmatrix(lcd_points, tp_points)!=0)); //calculate calibration matrix

  tp_init(); //reset touch

  lcd_clear(bgcolor);

  return;
}
예제 #21
0
void cmd_lcd_test(uint_least16_t fgcolor, uint_least16_t bgcolor)
{
  uint_least8_t c=1, f_save=features;
  char tmp[32];
#ifdef TP_SUPPORT
  uint_least16_t x, y, z, last_x=0, last_y=0;
  uint_least32_t ms=0;

  tp_init();
  ldr_init();
  features = FEATURE_TP | FEATURE_LDR; //FEATURE_TP | FEATURE_LDR
#else
  uint_least8_t sw;
  int_least8_t pos=0, hpos=0, vpos=0;

  enc_init();
  features = FEATURE_ENC;
#endif

  lcd_fillrect(0,                   0, (LCD_WIDTH-1)/3,     LCD_HEIGHT-1, RGB(255,0,0));
  lcd_fillrect((LCD_WIDTH-1)/3,     0, ((LCD_WIDTH-1)/3)*2, LCD_HEIGHT-1, RGB(0,255,0));
  lcd_fillrect(((LCD_WIDTH-1)/3)*2, 0, LCD_WIDTH-1,         LCD_HEIGHT-1, RGB(0,0,255));
/*
  delay_ms(1500);
  lcd_clear(bgcolor);

  lcd_setorientation(  0); lcd_drawrect(10, 20, 40, 40, RGB(200,  0,  0)); lcd_drawtext(15, 25, "0  ", 0, RGB(200,  0,  0), 0, 0);
  lcd_setorientation( 90); lcd_drawrect(10, 20, 40, 40, RGB(  0,200,  0)); lcd_drawtext(15, 25, "90 ", 0, RGB(  0,200,  0), 0, 0);
  lcd_setorientation(180); lcd_drawrect(10, 20, 40, 40, RGB(  0,  0,200)); lcd_drawtext(15, 25, "180", 0, RGB(  0,  0,200), 0, 0);
  lcd_setorientation(270); lcd_drawrect(10, 20, 40, 40, RGB(200,  0,200)); lcd_drawtext(15, 25, "270", 0, RGB(200,  0,200), 0, 0);

  lcd_setorientation(0);
  lcd_drawline(0, LCD_WIDTH/4*1, LCD_WIDTH-1, LCD_WIDTH/4*1, RGB(120,120,120));
  lcd_drawline(0, LCD_WIDTH/4*2, LCD_WIDTH-1, LCD_WIDTH/4*2, RGB(120,120,120));
  lcd_drawline(0, LCD_WIDTH/4*3, LCD_WIDTH-1, LCD_WIDTH/4*3, RGB(120,120,120));
  lcd_drawline(LCD_WIDTH/4*1, 0, LCD_WIDTH/4*1, LCD_HEIGHT-1, RGB(120,120,120));
  lcd_drawline(LCD_WIDTH/4*2, 0, LCD_WIDTH/4*2, LCD_HEIGHT-1, RGB(120,120,120));
  lcd_drawline(LCD_WIDTH/4*3, 0, LCD_WIDTH/4*3, LCD_HEIGHT-1, RGB(120,120,120));
  lcd_drawcircle(LCD_WIDTH/2, LCD_HEIGHT/2, 40, RGB(120,120,120));
*/

  lcd_drawtext(LCD_CENTER, LCD_HEIGHT/2-5, "v"VERSION, 0, 0, 0, 0);
  lcd_drawtext(LCD_CENTER, LCD_HEIGHT/2+5, "("__DATE__")", 0, 0, 0, 0);
  lcd_drawtext(LCD_CENTER, LCD_HEIGHT-10, "watterott.com", 1, 0, 0, 0);

  do
  {
#ifdef TP_SUPPORT
    tp_read();
    z = tp_getz();
    if(z)
    {
      x = tp_getx();
      y = tp_gety();
      if((x!=last_x) || (y!=last_y))
      {
        last_x = x;
        last_y = y;
        lcd_fillcircle(x, y, 4, fgcolor); //lcd_drawpixel(x, y);
        sprintf(tmp, "X%03i Y%03i Z%03i", x, x, z);
        lcd_drawtext(5, 5, tmp, 0, fgcolor, bgcolor, 1);
      }

      GPIO_SETPIN(LED_PORT, LED_PIN); //LED on
    }
    else
    {
      GPIO_CLRPIN(LED_PORT, LED_PIN); //LED off
    }

    if(features & FEATURE_LDR)
    {
      if((get_ms() - ms) >= 100)
      {
        ms = get_ms();
        x = ldr_service(100);
        sprintf(tmp, "LDR %03i", x);
        lcd_drawtext(5, 15, tmp, 0, fgcolor, bgcolor, 1);
      }
    }

#else //TP_SUPPORT

    pos  += enc_getdelta();
    hpos += nav_gethdelta();
    vpos += nav_getvdelta();
    sprintf(tmp, "P%03i H%03i V%03i", pos, hpos, vpos);
    lcd_drawtext(5, 5, tmp, 0, fgcolor, bgcolor, 1);

    sw  = enc_getsw();
    sw |= nav_getsw();
    if(sw)
    {
      GPIO_SETPIN(LED_PORT, LED_PIN); //LED on
      if(sw & 0x02)
      {
        if(features == FEATURE_ENC)
        {
          sprintf(tmp, "NAV");
          nav_init();
          features = FEATURE_NAV;
        }
        else //if(features == FEATURE_NAV)
        {
          sprintf(tmp, "ENC");
          enc_init();
          features = FEATURE_ENC;
        }
        lcd_drawtext(5, 25, tmp, 0, fgcolor, bgcolor, 1);
        delay_ms(500);
        while(enc_getsw() || nav_getsw());
      }
      else if(sw & 0x01)
      {
        lcd_drawtext(5, 15, "press", 0, fgcolor, bgcolor, 1);
      }
    }
    else
    {
      GPIO_CLRPIN(LED_PORT, LED_PIN); //LED off
    }
#endif
    if(if_available())
    {
      c = if_read8();
    }
  }while(c != 0);

  GPIO_CLRPIN(LED_PORT, LED_PIN); //LED off

  lcd_clear(bgcolor);

  features = f_save;

  return;
}