void isosurface_renderer_fraglist_raycasting::register_cuda_resources () { // map glresources to kernel resources cudaError_t cuda_err = cudaSuccess; register_buffer ( &_cuda_surface_data_buffer, _surface_data_texturebuffer, cudaGraphicsRegisterFlagsReadOnly ); register_buffer ( &_cuda_surface_points_buffer, _surface_points_texturebuffer, cudaGraphicsRegisterFlagsReadOnly ); register_buffer ( &_cuda_volume_data_buffer, _volume_data_texturebuffer, cudaGraphicsRegisterFlagsReadOnly ); register_buffer ( &_cuda_volume_points_buffer, _volume_points_texturebuffer, cudaGraphicsRegisterFlagsReadOnly ); register_buffer ( &_cuda_attribute_data_buffer, _attribute_data_texturebuffer, cudaGraphicsRegisterFlagsReadOnly ); register_buffer ( &_cuda_attribute_points_buffer, _attribute_points_texturebuffer, cudaGraphicsRegisterFlagsReadOnly ); if ( !_cuda_colorbuffer ) register_image ( &_cuda_colorbuffer, _colorattachment->id(), _colorattachment->target(), cudaGraphicsRegisterFlagsSurfaceLoadStore ); if ( !_cuda_depthbuffer ) register_image ( &_cuda_depthbuffer, _depthattachment->id(), _depthattachment->target(), cudaGraphicsRegisterFlagsSurfaceLoadStore );\ if ( !_cuda_headpointer ) register_image ( &_cuda_headpointer, _indextexture->id(), _indextexture->target(), cudaGraphicsRegisterFlagsSurfaceLoadStore ); if ( !_cuda_fragmentcount ) register_image ( &_cuda_fragmentcount, _fragmentcount->id(), _fragmentcount->target(), cudaGraphicsRegisterFlagsSurfaceLoadStore ); if ( _external_color_depth_texture ) register_image ( &_cuda_external_texture, _external_color_depth_texture->id(), _external_color_depth_texture->target(), cudaGraphicsRegisterFlagsSurfaceLoadStore ); register_buffer ( &_cuda_indexlist, *_indexlist, cudaGraphicsRegisterFlagsNone ); register_buffer ( &_cuda_matrixbuffer, *_matrixbuffer, cudaGraphicsRegisterFlagsReadOnly ); register_buffer ( &_cuda_allocation_grid, *_allocation_grid, cudaGraphicsRegisterFlagsNone ); }
/** * Execute script * * @v image Script * @ret rc Return status code */ static int script_exec ( struct image *image ) { size_t saved_offset; int rc; /* Temporarily de-register image, so that a "boot" command * doesn't throw us into an execution loop. */ unregister_image ( image ); /* Preserve state of any currently-running script */ saved_offset = script_offset; /* Process script */ rc = process_script ( image, script_exec_line, terminate_on_exit_or_failure ); /* Restore saved state */ script_offset = saved_offset; /* Re-register image (unless we have been replaced) */ if ( ! image->replacement ) register_image ( image ); return rc; }
/** * Initialise initrd * * @ret rc Return status code */ static int initrd_init ( void ) { struct image *image; int rc; /* Do nothing if no initrd was specified */ if ( ! initrd_phys ) { DBGC ( colour, "RUNTIME found no initrd\n" ); return 0; } if ( ! initrd_len ) { DBGC ( colour, "RUNTIME found empty initrd\n" ); return 0; } DBGC ( colour, "RUNTIME found initrd at [%x,%x)\n", initrd_phys, ( initrd_phys + initrd_len ) ); /* Allocate image */ image = alloc_image(); if ( ! image ) { DBGC ( colour, "RUNTIME could not allocate image for " "initrd\n" ); rc = -ENOMEM; goto err_alloc_image; } image_set_name ( image, "<INITRD>" ); /* Allocate and copy initrd content */ image->data = umalloc ( initrd_len ); if ( ! image->data ) { DBGC ( colour, "RUNTIME could not allocate %zd bytes for " "initrd\n", initrd_len ); rc = -ENOMEM; goto err_umalloc; } image->len = initrd_len; memcpy_user ( image->data, 0, phys_to_user ( initrd_phys ), 0, initrd_len ); /* Mark initrd as consumed */ initrd_phys = 0; /* Register image */ if ( ( rc = register_image ( image ) ) != 0 ) { DBGC ( colour, "RUNTIME could not register initrd: %s\n", strerror ( rc ) ); goto err_register_image; } /* Drop our reference to the image */ image_put ( image ); return 0; err_register_image: err_umalloc: image_put ( image ); err_alloc_image: return rc; }
/** * Initialise command line * * @ret rc Return status code */ static int cmdline_init ( void ) { userptr_t cmdline_user; char *cmdline; size_t len; int rc; /* Do nothing if no command line was specified */ if ( ! cmdline_phys ) { DBGC ( colour, "RUNTIME found no command line\n" ); return 0; } cmdline_user = phys_to_user ( cmdline_phys ); len = ( strlen_user ( cmdline_user, 0 ) + 1 /* NUL */ ); /* Allocate and copy command line */ cmdline_copy = malloc ( len ); if ( ! cmdline_copy ) { DBGC ( colour, "RUNTIME could not allocate %zd bytes for " "command line\n", len ); rc = -ENOMEM; goto err_alloc_cmdline_copy; } cmdline = cmdline_copy; copy_from_user ( cmdline, cmdline_user, 0, len ); DBGC ( colour, "RUNTIME found command line \"%s\" at %08x\n", cmdline, cmdline_phys ); /* Mark command line as consumed */ cmdline_phys = 0; /* Strip unwanted cruft from the command line */ cmdline_strip ( cmdline, "BOOT_IMAGE=" ); cmdline_strip ( cmdline, "initrd=" ); while ( isspace ( *cmdline ) ) cmdline++; DBGC ( colour, "RUNTIME using command line \"%s\"\n", cmdline ); /* Prepare and register image */ cmdline_image.data = virt_to_user ( cmdline ); cmdline_image.len = strlen ( cmdline ); if ( cmdline_image.len ) { if ( ( rc = register_image ( &cmdline_image ) ) != 0 ) { DBGC ( colour, "RUNTIME could not register command " "line: %s\n", strerror ( rc ) ); goto err_register_image; } } /* Drop our reference to the image */ image_put ( &cmdline_image ); return 0; err_register_image: image_put ( &cmdline_image ); err_alloc_cmdline_copy: return rc; }
void register_functions( lua_State* L, gwlua_t* state ) { static const luaL_Reg statics[] = { { "playsound", l_playsound }, { "stopsounds", l_stopsounds }, { "randomize", l_randomize }, { "random", l_random }, { "round", l_round }, { "now", l_now }, { "splittime", l_splittime }, { "inttostr", l_inttostr }, { "loadvalue", l_loadvalue }, { "savevalue", l_savevalue }, { "setbackground", l_setbackground }, { "setzoom", l_setzoom }, { "inputstate", l_inputstate }, { "loadbin", l_loadbin }, { "loadbs", l_loadbs }, { NULL, NULL } }; lua_newtable( L ); register_image( L, state ); register_sound( L, state ); register_timer( L, state ); lua_pushlightuserdata( L, (void*)state ); luaL_setfuncs( L, statics, 1 ); // module if ( luaL_loadbufferx( L, (const char*)gwlua_lua_system_lua, gwlua_lua_system_lua_len, "system.lua", "t" ) != LUA_OK ) { lua_error( L ); return; } // module chunk lua_call( L, 0, 1 ); // module function lua_pushvalue( L, -2 ); // module function module lua_call( L, 1, 0 ); // module lua_setglobal( L, "system" ); // -- }
ttransient_message::ttransient_message(const std::string& title , const bool title_use_markup , const std::string& message , const bool message_use_markup , const std::string& image) { register_label("title", true, title, title_use_markup); register_label("message", true, message, message_use_markup); register_image("image", true, image); }
static void register_native_filters (mathmap_t *mathmap) { userval_info_t *infos; infos = NULL; register_image(&infos, "in", 0); register_float_const(&infos, "horizontal_std_dev", 0.0, 2.0, 0.01); register_float_const(&infos, "vertical_std_dev", 0.0, 2.0, 0.01); register_native_filter(mathmap, "gaussian_blur", infos, TRUE, TRUE, "native_filter_gaussian_blur", &native_filter_gaussian_blur); infos = NULL; register_image(&infos, "in", 0); register_image(&infos, "kernel", 0); register_bool(&infos, "normalize", 1.0); register_bool(&infos, "copy_alpha", 1.0); register_native_filter(mathmap, "convolve", infos, TRUE, TRUE, "native_filter_convolve", &native_filter_convolve); infos = NULL; register_image(&infos, "in", 0); register_image(&infos, "mask", 0); register_bool(&infos, "copy_alpha", 1.0); register_native_filter(mathmap, "half_convolve", infos, TRUE, TRUE, "native_filter_half_convolve", &native_filter_half_convolve); infos = NULL; register_image(&infos, "in", 0); register_bool(&infos, "ignore_alpha", 1.0); register_native_filter(mathmap, "visualize_fft", infos, TRUE, TRUE, "native_filter_visualize_fft", &native_filter_visualize_fft); }
image_id _user_register_image(extended_image_info *userInfo, size_t size) { extended_image_info info; if (size != sizeof(info)) return B_BAD_VALUE; if (!IS_USER_ADDRESS(userInfo) || user_memcpy(&info, userInfo, size) < B_OK) return B_BAD_ADDRESS; return register_image(thread_get_current_thread()->team, &info, size); }
/** * Execute script * * @v image Script * @ret rc Return status code */ static int script_exec ( struct image *image ) { size_t offset = 0; off_t eol; size_t len; int rc; /* Temporarily de-register image, so that a "boot" command * doesn't throw us into an execution loop. */ unregister_image ( image ); while ( offset < image->len ) { /* Find length of next line, excluding any terminating '\n' */ eol = memchr_user ( image->data, offset, '\n', ( image->len - offset ) ); if ( eol < 0 ) eol = image->len; len = ( eol - offset ); /* Copy line, terminate with NUL, and execute command */ { char cmdbuf[ len + 1 ]; copy_from_user ( cmdbuf, image->data, offset, len ); cmdbuf[len] = '\0'; DBG ( "$ %s\n", cmdbuf ); if ( ( rc = system ( cmdbuf ) ) != 0 ) { DBG ( "Command \"%s\" failed: %s\n", cmdbuf, strerror ( rc ) ); goto done; } } /* Move to next line */ offset += ( len + 1 ); } rc = 0; done: /* Re-register image and return */ register_image ( image ); return rc; }
/** * Register all embedded images */ static void embedded_init ( void ) { int i; struct image *image; void *data; int rc; /* Skip if we have no embedded images */ if ( ! sizeof ( embedded_images ) ) return; /* Fix up data pointers and register images */ for ( i = 0 ; i < ( int ) ( sizeof ( embedded_images ) / sizeof ( embedded_images[0] ) ) ; i++ ) { image = &embedded_images[i]; /* virt_to_user() cannot be used in a static * initialiser, so we cast the pointer to a userptr_t * in the initialiser and fix it up here. (This will * actually be a no-op on most platforms.) */ data = ( ( void * ) image->data ); image->data = virt_to_user ( data ); DBG ( "Embedded image \"%s\": %zd bytes at %p\n", image->name, image->len, data ); if ( ( rc = register_image ( image ) ) != 0 ) { DBG ( "Could not register embedded image \"%s\": " "%s\n", image->name, strerror ( rc ) ); return; } } /* Select the first image */ image = &embedded_images[0]; if ( ( rc = image_select ( image ) ) != 0 ) { DBG ( "Could not select embedded image \"%s\": %s\n", image->name, strerror ( rc ) ); return; } }
status_t copy_images(team_id fromTeamId, Team *toTeam) { // get the team Team* fromTeam = Team::Get(fromTeamId); if (fromTeam == NULL) return B_BAD_TEAM_ID; BReference<Team> teamReference(fromTeam, true); MutexLocker locker(sImageMutex); struct image *image = NULL; while ((image = (struct image*)list_get_next_item(&fromTeam->image_list, image)) != NULL) { image_id id = register_image(toTeam, &image->info, sizeof(image->info), true); if (id < 0) return id; } return B_OK; }
/*! Registers an image with the specified team. */ image_id register_image(Team *team, extended_image_info *info, size_t size) { return register_image(team, info, size, false); }
void stagealign(int fcnum, int lane_num, int initialize) { short unsigned int *testimage; short unsigned int *baseimage; FILE *baseimgfp; FILE *offsetfp; /* used to dump score matrix to file when debugging */ FILE *score_matrixfp; /* Maestro declarations */ int m_sock; /* socket for the Maestro controller */ char config_value[255]; char logfilename[255]; char offsetfilename[255]; char stagealign_baseimgfilename[255]; char acqcfgpath[255]; /* Used to send commands and receive responses from Maestro */ char command[255]; char response[255]; int response_length; /* Image acquisition settings, populated from config file */ int stagealign_integration_inmsec; int stagealign_gain; int stagealign_well; int stagealign_wells_per_fc; /* Values used for conversion between pixels and stage units */ int stagealign_optical_mag; int ccd_pixel_size; double pixelsize_at_stage; /* size of a pixel at the stage in microns */ /* Hold offsets found by alignment in pixels and stageunits */ int pixel_offset_x, pixel_offset_y; double stageunit_offset_x, stageunit_offset_y; int lane_index; /* Holds previous offsets from controller in case the alignment doesn't work */ int curr_offset_x, curr_offset_y; /* Holds encoder resolutions from controller, used for calculating distance of move */ double encoder_res_X, encoder_res_Y; /* 'score' of best alignment */ int score; /* Largest pixel offset allowable _after_ the adjustment has been made */ /* if there is still a shift larger than this, conclude something is wrong */ /* and go back to the previous offset */ int successful_move_threshold = 150; /*RCT was = 12*/ int i; /* in debugging mode, dump internal data to files */ #ifdef DEBUG_STAGEALIGN FILE *imgfp; sprintf(command, "%s/stagealign-image%d_%d.raw", output_directory, fcnum, lane_num); imgfp = fopen(command, "w"); sprintf(command, "%s/stagealign-scorematrix%d_%d", output_directory, fcnum, lane_num); score_matrixfp = fopen(command, "w"); #endif p_log_simple("awesome2\n"); /* Open config file */ strcpy(acqcfgpath, getenv("POLONATOR_PATH")); strcat(acqcfgpath, "/config_files/polonator-acq.cfg"); config_open(acqcfgpath); p_log_simple("awesome1\n"); /* Initialize variables */ if(!config_getvalue("stagealign_logfilename", config_value)){ fprintf(stderr, "ERROR:\tPolonator-stagealign: config_getval(key logfilename) returned no value\n"); exit(0); } p_log_simple("awesome0\n"); strcpy(logfilename, log_dir); strcat(logfilename, "/"); strcat(logfilename, config_value); sprintf(command, "%d", fcnum); strcat(logfilename, command); strcat(logfilename, ".log"); p_log_simple(logfilename); start_logger(logfilename, 1); strcpy(offsetfilename, log_dir); strcat(offsetfilename, "/"); strcat(offsetfilename, config_value); strcat(offsetfilename, command); strcat(offsetfilename, ".offsetlog"); fprintf(stdout, offsetfilename); fflush(stdout); /* if this is being run in 'initialize mode' -- the first scan of a run -- overwrite the offset logfile */ p_log_simple("awesome66\n"); if(initialize){ offsetfp = fopen(offsetfilename, "w"); } else{ offsetfp = fopen(offsetfilename, "a"); } p_log_simple("awesome00\n"); if(!config_getvalue("stagealign_baseimgfilename", config_value)){ p_log("ERROR:\tPolonator-stagealign: config_getval(key stagealign_baseimgfilename) returned no value"); exit(0); } sprintf(stagealign_baseimgfilename, "%s/%s%s_%d.raw", output_directory, config_value, command, lane_num); p_log_simple("awesome01\n"); if(!config_getvalue("stagealign_integration_inmsec", config_value)){ p_log("ERROR:\tPolonator-stagealign: config_getval(key stagealign_integration_inmsec) returned no value"); exit(0); } stagealign_integration_inmsec = atoi(config_value); p_log_simple("awesome02\n"); if(!config_getvalue("stagealign_gain", config_value)){ p_log("ERROR:\tPolonator-stagealign: config_getval(key stagealign_gain) returned no value"); exit(0); } stagealign_gain = atoi(config_value); p_log_simple("awesome03\n"); if(!config_getvalue("stagealign_optical_mag", config_value)){ p_log("ERROR:\tPolonator-stagealign: config_getval(key stagealign_optical_mag) returned no value"); exit(0); } stagealign_optical_mag = atoi(config_value); p_log_simple("awesome04\n"); if(!config_getvalue("stagealign_ccd_pixel_size", config_value)){ p_log("ERROR:\tPolonator-stagealign: config_getval(key stagealign_ccd_pixel_size) returned no value"); exit(0); } ccd_pixel_size = atoi(config_value); p_log_simple("awesome05\n"); if(!config_getvalue("stagealign_wells_per_fc", config_value)){ p_log("ERROR:\tPolonator-stagealign: config_getval(key stagealign_wells_per_fc) returned no value"); exit(0); } stagealign_wells_per_fc = atoi(config_value); config_close(); p_log_simple("awesome06\n"); stagealign_well = lane_num; lane_index = (fcnum * stagealign_wells_per_fc) + stagealign_well; baseimage = (short unsigned int*)malloc(1000000 * sizeof(short unsigned int)); /*-------------------------------------------------------------------------- // // MAESTRO SETUP /*/ p_log_simple("STATUS:\tPolonator-stagealign: Opening connection to Maestro..."); maestro_open(&m_sock); /* //-------------------------------------------------------------------------- */ /*-------------------------------------------------------------------------- // // CAMERA SETUP /*/ p_log_simple("STATUS:\tPolonator-stagealign: Opening camera handle..."); py_cameraInit(0); /* use non-TDI config file */ py_set_gain(stagealign_gain); py_setupSnap(); /* setup capture software to wait for images from camera */ /* //-------------------------------------------------------------------------- */ /*p_log("STATUS:\tPolonator-stagealign: Darkfield illuminator on..."); rolony*/ /*maestro_darkfield_on(m_sock); p_log("STATUS:\tPolonator-stagealign: Select darkfield filter block..."); rolony*/ maestro_setcolor(m_sock, "cy5"); /* IF INITIALIZING, RESET OFFSETS */ if(initialize){ p_log_simple("INITIALIZING STAGEALIGN"); sprintf(command, "PolonatorScan.OFFSET_X[%d]=0\n\r", lane_index); p_log_simple(command); send(m_sock, command, strlen(command), 0); maestro_readresponse(m_sock, response, &response_length); p_log_simple(response); sprintf(command, "PolonatorScan.OFFSET_Y[%d]=0\n\r", lane_index); p_log_simple(command); send(m_sock, command, strlen(command), 0); maestro_readresponse(m_sock, response, &response_length); p_log_simple(response); } /* GET OFFSETS IN CASE ALIGNMENT FAILS */ else{ p_log_simple("Storing current offsets..."); sprintf(command, "PolonatorScan.OFFSET_X[%d]\n\r", lane_index); p_log_simple(command); send(m_sock, command, strlen(command), 0); maestro_readresponse(m_sock, response, &response_length); p_log_simple(response); curr_offset_x = atoi(response); sprintf(command, "PolonatorScan.OFFSET_Y[%d]\n\r", lane_index); p_log_simple(command); send(m_sock, command, strlen(command), 0); maestro_readresponse(m_sock, response, &response_length); p_log_simple(response); curr_offset_y = atoi(response); } /* MOVE STAGE TO ORIGIN */ maestro_gotostagealign_position(m_sock, fcnum, lane_num); p_log_simple("awesome fool00\n"); /* ACQUIRE IMAGE */ p_log("STATUS:\tPolonator-stagealign: Acquire image..."); maestro_snap(m_sock, stagealign_integration_inmsec, 1); /*rolony*/ while(!py_snapReceived()){;} testimage = py_getSnapImage(); /* IF INITIALIZING, RE-WRITE THE BASE IMAGE; THE OFFSET FOUND SHOULD BE ZERO */ p_log_simple(stagealign_baseimgfilename); if(initialize){ baseimgfp = fopen(stagealign_baseimgfilename, "w"); fwrite(testimage, 1000000, sizeof(short unsigned int), baseimgfp); fclose(baseimgfp); } p_log_simple("awesome fool01\n"); #ifdef DEBUG_STAGEALIGN fwrite(testimage, 1000000, sizeof(short unsigned int), imgfp); #endif /* LOAD BASE IMAGE */ p_log("STATUS:\tPolonator-stagealign: Load base image and determine offset..."); baseimgfp = fopen(stagealign_baseimgfilename, "r"); fread(baseimage, 1000000, sizeof(short unsigned int), baseimgfp); fclose(baseimgfp); p_log("STATUS:\tPolonator-stagealign: Load base image and determine offset2..."); /* DETERMINE OFFSETS */ register_image(baseimage, testimage, &pixel_offset_x, &pixel_offset_y, &score, score_matrixfp); sprintf(log_string, "STATUS:\tPolonator-stagealign: Found pixel offsets X:%d, Y:%d, score:%d", pixel_offset_x, pixel_offset_y, score); p_log(log_string); /* LOAD ENCODER RESOLUTIONS FOR CONVERSION BELOW; THESE ARE STORED ON */ /* THE CONTROLLER AS COUNTS PER MILLIMETER */ p_log("Retrieving encoder resolutions..."); sprintf(command, "PolonatorScan.cENCODER_X_RESOLUTION\n\r"); p_log(command); send(m_sock, command, strlen(command), 0); maestro_readresponse(m_sock, response, &response_length); p_log(response); encoder_res_X = atof(response); sprintf(command, "PolonatorScan.cENCODER_Y_RESOLUTION\n\r"); p_log(command); send(m_sock, command, strlen(command), 0); maestro_readresponse(m_sock, response, &response_length); p_log(response); encoder_res_Y = atof(response); /* CONVERT FROM PIXELS TO STAGE UNITS */ /* CALCULATE PIXEL SIZE IN MILLIMTERS AT THE STAGE BASED */ /* ON THE MAGNIFICATION AND THE CCD PIXEL SIZE */ pixelsize_at_stage = ((double)ccd_pixel_size / (double)stagealign_optical_mag) / 1000; stageunit_offset_x = (double)pixel_offset_x * pixelsize_at_stage * encoder_res_X * -1; stageunit_offset_y = (double)pixel_offset_y * pixelsize_at_stage * encoder_res_Y * -1; /* SET NEW OFFSETS ON CONTROLLER USING VALUES */ /* CALCULATED ABOVE */ sprintf(command, "PolonatorScan.OFFSET_X[%d]\n\r", lane_index); send(m_sock, command, strlen(command), 0); maestro_readresponse(m_sock, response, &response_length); fprintf(offsetfp, "%d\t%d\t", fcnum, stagealign_well); fprintf(offsetfp, "%d\t", atoi(response)); sprintf(command, "PolonatorScan.OFFSET_Y[%d]\n\r", lane_index); send(m_sock, command, strlen(command), 0); maestro_readresponse(m_sock, response, &response_length); fprintf(offsetfp, "%d\t", atoi(response)); fprintf(offsetfp, "%d\t%d\t%d\t%d\t", (int)stageunit_offset_x, (int)stageunit_offset_y, pixel_offset_x, pixel_offset_y); /* ISSUE COMMANDS TO ADJUST STAGE COORDS */ p_log("STATUS:\tPolonator-stagealign: Set offset variables on Maestro..."); sprintf(command, "PolonatorScan.OFFSET_X[%d]=PolonatorScan.OFFSET_X[%d]+%d\n\r", lane_index, lane_index, (int)stageunit_offset_x); p_log(command); send(m_sock, command, strlen(command), 0); maestro_readresponse(m_sock, response, &response_length); p_log(response); sprintf(command, "PolonatorScan.OFFSET_Y[%d]=PolonatorScan.OFFSET_Y[%d]+%d\n\r", lane_index, lane_index, (int)stageunit_offset_y); p_log(command); send(m_sock, command, strlen(command), 0); maestro_readresponse(m_sock, response, &response_length); p_log(response); /* MOVE, THEN ACQUIRE ANOTHER IMAGE TO VERIFY OFFSET WORKED */ /* maestro_gotostagealign_position(m_sock, fcnum, lane_num); maestro_snap(m_sock, stagealign_integration_inmsec, 0); while(!py_snapReceived()){;} testimage = py_getSnapImage(); */ #ifdef DEBUG_STAGEALIGN fwrite(testimage, 1000000, sizeof(short unsigned int), imgfp); fclose(imgfp); #endif /* DETERMINE OFFSET TO CONFIRM */ /* p_log("STATUS:\tPolonator-stagealign: Re-compute alignment to verify move..."); register_image(baseimage, testimage, &pixel_offset_x, &pixel_offset_y, &score, score_matrixfp); sprintf(log_string, "STATUS:\tPolonator-stagealign: Found pixel offsets X:%d, Y:%d, score:%d", pixel_offset_x, pixel_offset_y, score); p_log(log_string); fprintf(offsetfp, "%d\t%d", pixel_offset_x, pixel_offset_y); */ /* DID THE MOVE WORK? */ if(((abs(pixel_offset_x)>successful_move_threshold) || (abs(pixel_offset_y)>successful_move_threshold)) && (!initialize)) { sprintf(log_string, "ERROR:\tPolonator-stagealign: one or more offsets are greater that the %d-pixel maximum; X:%d, Y:%d", successful_move_threshold, pixel_offset_x, pixel_offset_y); p_log(log_string); fprintf(offsetfp, "*"); /* mark current line in offsetlog, since offsets found will not be the offsets stored on the controller */ sprintf(log_string, "Restoring previous offsets X:%d, Y:%d", curr_offset_x, curr_offset_y); sprintf(command, "PolonatorScan.OFFSET_X[%d]=%d\n\r", lane_index, curr_offset_x); p_log(command); send(m_sock, command, strlen(command), 0); maestro_readresponse(m_sock, response, &response_length); p_log(response); sprintf(command, "PolonatorScan.OFFSET_Y[%d]=%d\n\r", lane_index, curr_offset_y); p_log(command); send(m_sock, command, strlen(command), 0); maestro_readresponse(m_sock, response, &response_length); p_log(response); } /* EXIT */ #ifdef DEBUG_STAGEALIGN fclose(score_matrixfp); #endif fprintf(offsetfp, "\n"); fclose(offsetfp); /*maestro_darkfield_off(m_sock); rolony*/ py_cameraClose(); free(baseimage); close_logger(); p_log_simple("awesome fool02\n"); }
status_t load_image(char const* name, image_type type, const char* rpath, const char* requestingObjectPath, image_t** _image) { int32 pheaderSize, sheaderSize; char path[PATH_MAX]; ssize_t length; char pheaderBuffer[4096]; int32 numRegions; image_t* found; image_t* image; status_t status; int fd; elf_ehdr eheader; // Have we already loaded that image? Don't check for add-ons -- we always // reload them. if (type != B_ADD_ON_IMAGE) { found = find_loaded_image_by_name(name, APP_OR_LIBRARY_TYPE); if (found == NULL && type != B_APP_IMAGE && gProgramImage != NULL) { // Special case for add-ons that link against the application // executable, with the executable not having a soname set. if (const char* lastSlash = strrchr(name, '/')) { if (strcmp(gProgramImage->name, lastSlash + 1) == 0) found = gProgramImage; } } if (found) { atomic_add(&found->ref_count, 1); *_image = found; KTRACE("rld: load_container(\"%s\", type: %d, rpath: \"%s\") " "already loaded", name, type, rpath); return B_OK; } } KTRACE("rld: load_container(\"%s\", type: %d, rpath: \"%s\")", name, type, rpath); strlcpy(path, name, sizeof(path)); // find and open the file fd = open_executable(path, type, rpath, get_program_path(), requestingObjectPath, sSearchPathSubDir); if (fd < 0) { FATAL("Cannot open file %s: %s\n", name, strerror(fd)); KTRACE("rld: load_container(\"%s\"): failed to open file", name); return fd; } // normalize the image path status = _kern_normalize_path(path, true, path); if (status != B_OK) goto err1; // Test again if this image has been registered already - this time, // we can check the full path, not just its name as noted. // You could end up loading an image twice with symbolic links, else. if (type != B_ADD_ON_IMAGE) { found = find_loaded_image_by_name(path, APP_OR_LIBRARY_TYPE); if (found) { atomic_add(&found->ref_count, 1); *_image = found; _kern_close(fd); KTRACE("rld: load_container(\"%s\"): already loaded after all", name); return B_OK; } } length = _kern_read(fd, 0, &eheader, sizeof(eheader)); if (length != sizeof(eheader)) { status = B_NOT_AN_EXECUTABLE; FATAL("%s: Troubles reading ELF header\n", path); goto err1; } status = parse_elf_header(&eheader, &pheaderSize, &sheaderSize); if (status < B_OK) { FATAL("%s: Incorrect ELF header\n", path); goto err1; } // ToDo: what to do about this restriction?? if (pheaderSize > (int)sizeof(pheaderBuffer)) { FATAL("%s: Cannot handle program headers bigger than %lu\n", path, sizeof(pheaderBuffer)); status = B_UNSUPPORTED; goto err1; } length = _kern_read(fd, eheader.e_phoff, pheaderBuffer, pheaderSize); if (length != pheaderSize) { FATAL("%s: Could not read program headers: %s\n", path, strerror(length)); status = B_BAD_DATA; goto err1; } numRegions = count_regions(path, pheaderBuffer, eheader.e_phnum, eheader.e_phentsize); if (numRegions <= 0) { FATAL("%s: Troubles parsing Program headers, numRegions = %" B_PRId32 "\n", path, numRegions); status = B_BAD_DATA; goto err1; } image = create_image(name, path, numRegions); if (image == NULL) { FATAL("%s: Failed to allocate image_t object\n", path); status = B_NO_MEMORY; goto err1; } status = parse_program_headers(image, pheaderBuffer, eheader.e_phnum, eheader.e_phentsize); if (status < B_OK) goto err2; if (!assert_dynamic_loadable(image)) { FATAL("%s: Dynamic segment must be loadable (implementation " "restriction)\n", image->path); status = B_UNSUPPORTED; goto err2; } status = map_image(fd, path, image, eheader.e_type == ET_EXEC); if (status < B_OK) { FATAL("%s: Could not map image: %s\n", image->path, strerror(status)); status = B_ERROR; goto err2; } if (!parse_dynamic_segment(image)) { FATAL("%s: Troubles handling dynamic section\n", image->path); status = B_BAD_DATA; goto err3; } if (eheader.e_entry != 0) image->entry_point = eheader.e_entry + image->regions[0].delta; analyze_image_haiku_version_and_abi(fd, image, eheader, sheaderSize, pheaderBuffer, sizeof(pheaderBuffer)); // If this is the executable image, we init the search path // subdir, if the compiler version doesn't match ours. if (type == B_APP_IMAGE) { #if __GNUC__ == 2 if ((image->abi & B_HAIKU_ABI_MAJOR) == B_HAIKU_ABI_GCC_4) sSearchPathSubDir = "x86"; #elif __GNUC__ >= 4 if ((image->abi & B_HAIKU_ABI_MAJOR) == B_HAIKU_ABI_GCC_2) sSearchPathSubDir = "x86_gcc2"; #endif } set_abi_version(image->abi); // init gcc version dependent image flags // symbol resolution strategy if (image->abi == B_HAIKU_ABI_GCC_2_ANCIENT) image->find_undefined_symbol = find_undefined_symbol_beos; // init version infos status = init_image_version_infos(image); image->type = type; register_image(image, fd, path); image_event(image, IMAGE_EVENT_LOADED); _kern_close(fd); enqueue_loaded_image(image); *_image = image; KTRACE("rld: load_container(\"%s\"): done: id: %" B_PRId32 " (ABI: %#" B_PRIx32 ")", name, image->id, image->abi); return B_OK; err3: unmap_image(image); err2: delete_image_struct(image); err1: _kern_close(fd); KTRACE("rld: load_container(\"%s\"): failed: %s", name, strerror(status)); return status; }
userval_info_t* arg_decls_to_uservals (filter_t *filter, arg_decl_t *arg_decls) { userval_info_t *infos = NULL; while (arg_decls != 0) { userval_info_t *result = 0; if (lookup_userval(infos, arg_decls->name) != NULL) { sprintf(error_string, _("The argument `%s' is declared more than once."), arg_decls->name); error_region = arg_decls->region; JUMP(1); } switch (arg_decls->type) { case ARG_TYPE_INT : if (arg_decls->v.integer.have_limits) result = register_int_const(&infos, arg_decls->name, arg_decls->v.integer.min, arg_decls->v.integer.max, arg_decls->v.integer.default_value); else result = register_int_const(&infos, arg_decls->name, -100000, 100000, 0); break; case ARG_TYPE_FLOAT : if (arg_decls->v.floating.have_limits) result = register_float_const(&infos, arg_decls->name, arg_decls->v.floating.min, arg_decls->v.floating.max, arg_decls->v.floating.default_value); else result = register_float_const(&infos, arg_decls->name, -1.0, 1.0, 0.0); break; case ARG_TYPE_BOOL : result = register_bool(&infos, arg_decls->name, arg_decls->v.boolean.default_value); break; case ARG_TYPE_COLOR : result = register_color(&infos, arg_decls->name); break; case ARG_TYPE_GRADIENT : result = register_gradient(&infos, arg_decls->name); break; case ARG_TYPE_CURVE : result = register_curve(&infos, arg_decls->name); break; case ARG_TYPE_FILTER : assert(0); case ARG_TYPE_IMAGE : result = register_image(&infos, arg_decls->name, image_flags_from_options(arg_decls->options)); break; default : assert(0); } if (result == 0) { sprintf(error_string, _("Conflict for argument %s."), arg_decls->name); error_region = arg_decls->region; JUMP(1); } arg_decls = arg_decls->next; } return infos; }