//////////////////////////////////////////////////////////// // Push down any data from the old tree onto the new tree // by doing a traversal over the deleted clusters ////////////////////////////////////////////////////////// void pushDown(cluster* cl) { cluster* ccl; int i; assert(cl); ccl = GET_CL(cl); deprintf("pushDown: cl = %d\n",ccl->id); cluster** clusters = ccl->getClusters(); for(i=0; i < MAX_DEGREE; ++i) { cluster* child = clusters[i]; cluster* ccp = GET_CL(child); if(child) { pushDownFun(ccl,ccp); if(isDeleted(ccp)) { if(ccp->child) { deprintf("Child\n"); pushDown(child); deprintf("ret\n"); } freeCluster(ccp); } } } free(clusters); }
int PSL1GHT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) { deprintf(1, "+PSL1GHT_SetDisplayMode()\n"); PSL1GHT_DisplayModeData *dispdata = (PSL1GHT_DisplayModeData *) mode->driverdata; videoState state; /* Set the new DisplayMode */ printf("Setting PS3_MODE to %u\n", dispdata->vconfig.resolution); if ( videoConfigure(0, &dispdata->vconfig, NULL, 0) != 0) { deprintf(2, "Could not set PS3FB_MODE\n"); SDL_SetError("Could not set PS3FB_MODE\n"); return -1; } // Wait until RSX is ready do{ SDL_Delay(10); assert( videoGetState(0, 0, &state) == 0); }while ( state.state == 3); deprintf(1, "-PSL1GHT_SetDisplayMode()\n"); return 0; }
/* print some of the vertex information */ void printVertex (node* v) { deprintf ("VERTEX:\n"); deprintf ("\t id = %d\n", v->nId); deprintf ("\t degree = %d\n", v->degree); }
int center(cluster* root) { deprintf ("."); int cntr = traverse(root, -1, -1.0, -1, -1.0); deprintf("center is %d\n\n",cntr); return cntr; }
static void PS3_DeleteDevice(SDL_VideoDevice * device) { deprintf(1, "+PS3_DeleteDevice()\n"); SDL_free(device->driverdata); SDL_free(device); deprintf(1, "-PS3_DeleteDevice()\n"); }
int main(int argc, char **argv) { int opt; int daemon = 0; int port = SERVER_PORT; int server_fd; pid_t pid, sid; /* Launch options */ while ((opt = getopt(argc, argv, "dvp:")) != -1) { switch (opt) { case 'd': daemon = 1; break; case 'v': debug = 1; break; case 'p': port = atoi(optarg); break; default: printf("Usage: %s [-d] [-v] [-p port]\n", argv[0]); exit(EXIT_FAILURE); break; } } /* Signal handling */ register_signals(); deprintf ("Starting at port %d\n", port); /* Daemonify */ if (daemon) { deprintf ("Starting as daemon\n"); pid = fork(); if (pid < 0) { exit(EXIT_FAILURE); } else if (pid > 0) { exit(EXIT_SUCCESS); } umask(0); sid = setsid(); if (sid < 0) { exit(EXIT_FAILURE); } } /* INIT client nodes */ TAILQ_INIT(&client_nodes); server_fd = server_init(port); server_shutdown(server_fd); printf("Shutting down server.\n"); return 0; }
int PS3_FlipDoubleBuffer(_THIS, SDL_Surface * surface) { unsigned long crt = 0; deprintf(1, "[PS3] Wait for vsync\n"); ioctl(fb_dev_fd, FBIO_WAITFORVSYNC, &crt); deprintf(1, "[PS3] Page flip to buffer #%u 0x%x\n", s_center_index, s_center[s_center_index]); ioctl(fb_dev_fd, PS3FB_IOCTL_FSEL, (unsigned long)&s_center_index); return 1; }
/////////////////////////////////////////////////////// // Go over the list of old trees, and for each one of // them push down their data onto the new trees /////////////////////////////////////////////////////// void pushDownList(clusterList* rootList) { while(rootList->head != NULL) { cluster* cl = removeCluster(rootList); pushDown(cl); freeBlock(currentTree->UClusters,(char*) cl); deprintf("done 1\n"); } deprintf("done\n"); }
static int PS3_Available(void) { deprintf(1, "+PS3_Available()\n"); const char *envr = SDL_getenv("SDL_VIDEODRIVER"); if ((envr) && (SDL_strcmp(envr, PS3VID_DRIVER_NAME) == 0)) { return (1); } deprintf(1, "-PS3_Available()\n"); return (0); }
int SPE_WaitForMsg(_THIS, spu_data_t * spe_data, unsigned int msg) { deprintf(2, "[PS3->SPU] Waiting for message from %s\n", spe_data->program_name); unsigned int out_messages[1]; while (!spe_out_mbox_status(spe_data->ctx)); int mbox_read = spe_out_mbox_read(spe_data->ctx, out_messages, 1); deprintf(2, "[PS3->SPU] Got message from %s, message was %u\n", spe_data->program_name, out_messages[0]); if (out_messages[0] == msg) return 0; else return -1; }
/* Code running on SPU */ int main(unsigned long long spe_id __attribute__ ((unused)), unsigned long long argp __attribute__ ((unused))) { deprintf("[SPU] fb_writer_spu is up... (on SPE #%llu)\n", spe_id); uint32_t ea_mfc, mbox; // send ready message spu_write_out_mbox(SPU_READY); while (1) { /* Check mailbox */ mbox = spu_read_in_mbox(); deprintf("[SPU] Message is %u\n", mbox); switch (mbox) { case SPU_EXIT: deprintf("[SPU] fb_writer goes down...\n"); return 0; case SPU_START: break; default: deprintf("[SPU] Cannot handle message\n"); continue; } /* Tag Manager setup */ unsigned int tags; tags = mfc_multi_tag_reserve(5); if (tags == MFC_TAG_INVALID) { deprintf("[SPU] Failed to reserve mfc tags on fb_writer\n"); return 0; } /* Framebuffer parms */ ea_mfc = spu_read_in_mbox(); deprintf("[SPU] Message on fb_writer is %u\n", ea_mfc); spu_mfcdma32(&parms, (unsigned int)ea_mfc, sizeof(struct fb_writer_parms_t), tags, MFC_GET_CMD); deprintf("[SPU] argp = %u\n", (unsigned int)argp); DMA_WAIT_TAG(tags); /* Copy parms->data to framebuffer */ deprintf("[SPU] Copying to framebuffer started\n"); cpy_to_fb(tags); deprintf("[SPU] Copying to framebuffer done!\n"); mfc_multi_tag_release(tags, 5); deprintf("[SPU] fb_writer_spu... done!\n"); /* Send FIN msg */ spu_write_out_mbox(SPU_FIN); } return 0; }
int SPE_Stop(_THIS, spu_data_t * spe_data) { deprintf(2, "[PS3->SPU] Stop SPE: %s\n", spe_data->program_name); deprintf(2, "[PS3->SPU] Wait for SPE thread to complete: %s\n", spe_data->program_name); if (pthread_join(spe_data->thread, NULL)) { deprintf(2, "[PS3->SPU] Failed joining the thread: %s\n", spe_data->program_name); SDL_SetError("[PS3->SPU] Failed joining the thread"); return -1; } return 0; }
///////////////////////////////////////////////////////////// // To free the cluster, find out which pool it came from and // put it back there ///////////////////////////////////////////////////////////// void freeCluster(cluster* cl) { deprintf("freeCluster %p\n",cl); if(cl->endpoints == 2) { drun(bcs--); deprintf("free binary\n"); freeBlock(currentTree->BClusters,(char*) cl); } else { deprintf("free non-bnary\n"); drun(ucs--); freeBlock(currentTree->UClusters,(char*) cl); } }
/////////////////////////////////////////////////////////////// // rerun is to do a rerun // Takes the elements of the queue, if there is no more // work it breaks, if it is a copy event is calculates the // degree puts it in the node and makes sure the node has // a child, and if it is a run event it runs the wake up // code ///////////////////////////////////////////////////////////// cluster* rerun(Queue *q,tree_t* tree, int doSynch) { cluster* root; node *nd = NULL; int curheight = -1; deprintf(" \n Rerunning \n"); currentTree = tree; currentQueue = q; morework=1; //debug=1; while (!isEmpty(q)) { // Loop // Free the qnode drun(assert(!isEmpty(q))); nd = removeQueue(q); if(!(nd->deleted)) { //If it is the end of a round then check if all is done, otherwise continue, resetting //the morework flag if(nd->height != curheight) { curheight = nd->height; deprintf("Height is %d\n",curheight); if(morework == 0) break; morework = 0; } deprintf("Running %d\n",nd->nId); runNode(nd,q); drun(assert(verifyVertex(nd))); } }//while // Empty the queue emptyQueue(q); if(PUSHDOWN) { deprintf("push down\n"); pushDownList(&oldRootList); } if(doSynch) { root = syncList(&newRootList); } return root; }
void freeVertexCluster(cluster* cl,tree_t* tree) { deprintf("freeCluster %p\n",cl); if(cl->endpoints == 2) { deprintf("free binary\n"); bcs--; freeBlock(tree->BClusters,(char*) cl); } else { deprintf("free non-bnary\n"); ucs--; freeBlock(tree->UClusters,(char*) cl); } }
int SPE_SendMsg(_THIS, spu_data_t * spe_data, unsigned int msg) { deprintf(2, "[PS3->SPU] Sending message %u to %s\n", msg, spe_data->program_name); unsigned int spe_in_mbox_msgs[1]; spe_in_mbox_msgs[0] = msg; int in_mbox_write = spe_in_mbox_write(spe_data->ctx, spe_in_mbox_msgs, 1, SPE_MBOX_ALL_BLOCKING); if (1 > in_mbox_write) { deprintf(2, "[PS3->SPU] No message could be written to %s\n", spe_data->program_name); SDL_SetError("[PS3->SPU] No message could be written"); return -1; } return 0; }
void PS3_VideoQuit(_THIS) { deprintf(1, "PS3_VideoQuit()\n"); SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; PS3_QuitModes(_this); /* Unmap framebuffer */ if (data->frame_buffer) { struct fb_fix_screeninfo fb_finfo; if (ioctl(data->fbdev, FBIOGET_FSCREENINFO, &fb_finfo) != -1) { munmap(data->frame_buffer, fb_finfo.smem_len); data->frame_buffer = 0; } } /* Shutdown SPE and related resources */ if (data->fb_parms) free((void *)data->fb_parms); if (data->fb_thread_data) { SPE_Shutdown(data->fb_thread_data); free((void *)data->fb_thread_data); } /* Close device */ if (data->fbdev) { /* Give control of frame buffer back to kernel */ ioctl(data->fbdev, PS3FB_IOCTL_OFF, 0); close(data->fbdev); data->fbdev = -1; } }
void PSL1GHT_QuitModes(_THIS) { deprintf(1, "+PSL1GHT_QuitModes()\n"); /* There was no mem allocated for driverdata */ int i, j; for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) { SDL_VideoDisplay *display = &_this->displays[i]; for (j = display->num_display_modes; j--;) { display->display_modes[j].driverdata = NULL; } } // TODO : Free data deprintf(1, "-PSL1GHT_QuitModes()\n"); }
static SDL_VideoDevice * PSL1GHT_CreateDevice(int devindex) { SDL_VideoDevice *device; deprintf (1, "PSL1GHT_CreateDevice( %16X)\n", devindex); /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); if (device) { SDL_memset(device, 0, (sizeof *device)); } else { SDL_OutOfMemory(); SDL_free(device); return (0); } /* Set the function pointers */ device->VideoInit = PSL1GHT_VideoInit; device->VideoQuit = PSL1GHT_VideoQuit; device->SetDisplayMode = PSL1GHT_SetDisplayMode; device->GetDisplayModes = PSL1GHT_GetDisplayModes; device->PumpEvents = PSL1GHT_PumpEvents; device->free = PSL1GHT_DeleteDevice; return device; }
void signal_handler(int sig) { deprintf("Received signal: %d\n", sig); switch (sig) { case SIGTERM: case SIGHUP: case SIGINT: event_loopexit(NULL); break; case SIGPIPE: deprintf("Received SIGPIPE\n"); break; default: syslog(LOG_WARNING, "Uhandled signal %d", sig); break; } }
static void PS3_VideoQuit(_THIS) { if (fb_dev_fd > 0) { if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo)) SDL_SetError("[PS3] Can't restore original fb_var_screeninfo"); ioctl(fb_dev_fd, PS3FB_IOCTL_OFF, 0); close(fb_dev_fd); fb_dev_fd = -1; } if (frame_buffer) { munmap(frame_buffer, fb_finfo.smem_len); frame_buffer = 0; } if (fb_parms) free((void *)fb_parms); if (fb_thread_data) { SPE_Shutdown(this, fb_thread_data); free((void *)fb_thread_data); } if (this->screen) { if (double_buffering && this->screen->pixels) { free(this->screen->pixels); } this->screen->pixels = NULL; } enable_cursor(1); deprintf(1, "[PS3] VideoQuit\n"); }
void PS3_DoubleBufferUpdate(_THIS, int numrects, SDL_Rect * rects) { if (converter_thread_data && converter_thread_data->booted) SPE_WaitForMsg(this, converter_thread_data, SPU_FIN); s_bounded_input_width_offset = (s_writeable_width - s_bounded_input_width) >> 1; s_bounded_input_height_offset = (s_writeable_height - s_bounded_input_height) >> 1; s_center[0] = frame_buffer + s_bounded_input_width_offset * s_fb_pixel_size + s_bounded_input_height_offset * fb_finfo.line_length; s_center[1] = s_center[0] + real_height * fb_finfo.line_length; fb_parms->data = (unsigned char *)s_pixels; fb_parms->center = s_center[s_center_index]; fb_parms->out_line_stride = fb_finfo.line_length; fb_parms->in_line_stride = s_input_line_length; fb_parms->bounded_input_height = s_bounded_input_height; fb_parms->bounded_input_width = s_bounded_input_width; fb_parms->fb_pixel_size = s_fb_pixel_size; deprintf(3, "[PS3->SPU] fb_thread_data->argp = 0x%x\n", fb_thread_data->argp); SPE_SendMsg(this, fb_thread_data, SPU_START); SPE_SendMsg(this, fb_thread_data, (unsigned int)fb_thread_data->argp); SPE_WaitForMsg(this, fb_thread_data, SPU_FIN); if (double_buffering) s_center_index = s_center_index ^ 0x01; PS3_FlipDoubleBuffer(this, this->screen); }
///////////////////////////////////////////////////////////////// // To do the data propagation travese each new tree, and do a // post-order update. ///////////////////////////////////////////////////////////////// cluster* syncList(clusterList* rootList) { cluster* cl=NULL; int odebug = debug; //debug =1; while(rootList->head != NULL) { deprintf("Synch \n"); cl = removeCluster(rootList); synchronizeClusterContract(cl); deprintf("done 1\n"); } debug = odebug; deprintf("done\n"); return cl; }
/* Find the clusters with the two largest distances from the distinguished endpints, adjusting for being in a subcluster */ void find2max(cluster* curcl, cluster** child, double* max2,int ep1,double w1,int ep2,double w2) { int i; double max1; double effMax; bin_cluster** binaryCl; unary_cluster** unaryCl; max1 = *max2 = 0; binaryCl = (bin_cluster**) curcl->getBinaryClusters(); unaryCl = (unary_cluster**) curcl->getUnaryClusters(); for (i = 0; i < curcl->endpoints; ++i) { bin_cluster* cl = binaryCl[i]; if(cl) { bin_data* d = getBinData(cl); double mpath = getThisData(d); double len = getLen(d); deprintf("Binary cluster \n"); if((GET_CL(cl))->isEndPoint(ep1)) effMax = dmax(mpath,w1+len); else effMax = dmax(mpath,w2+len); deprintf("mpath is %lf, len is %lf \n",mpath, len); deprintf("w1 is %lf, w2 is %lf, ep1 is %d, ep2 is %d\n",w1,w2,ep1,ep2); deprintf("i is %d, effMax is %lf, max1 is %lf\n", i, effMax,max1); if(effMax > max1) {*max2 = max1; *child = cl; max1 = effMax;} else if(effMax > *max2) {*max2 = effMax;} } } for(i=0;i<MAX_DEGREE-curcl->endpoints;i++) { unary_cluster* cl = unaryCl[i]; if(cl) { double mpath = cl->data.mpath; effMax = mpath; deprintf("i is %d, effMax is %lf, max1 is %lf\n", i, effMax,max1); if(effMax > max1) {*max2 = max1; *child = cl; max1 = effMax;} else if(effMax > *max2) {*max2 = effMax;} } } }
int SPE_Shutdown(_THIS, spu_data_t * spe_data) { if (spe_data->keepalive && spe_data->booted) { SPE_SendMsg(this, spe_data, SPU_EXIT); SPE_Stop(this, spe_data); } deprintf(2, "[PS3->SPU] Destroy SPE context: %s\n", spe_data->program_name); if (spe_context_destroy(spe_data->ctx)) { deprintf(2, "[PS3->SPU] Failed destroying context: %s\n", spe_data->program_name); SDL_SetError("[PS3->SPU] Failed destroying context"); return -1; } deprintf(2, "[PS3->SPU] SPE shutdown successful: %s\n", spe_data->program_name); return 0; }
void desuccess(const char *s, const char *ex, struct demeta *dm, int f) { atomic_fetch_add(&dm->succeeded, 1); if (!(f & DE_QUIET)) { deprintf("%s when %s, succeeded at %s:%d\n", s, ex, dm->file, dm->line); } }
void setupBinVertexCluster (node* thisNode, int event,tree_t* tree, clusterList* rootList) { int i, j=0,k=0; cluster *cll; bin_cluster *cl; cluster* oldCluster = thisNode->vertex->cl; cl = new (allocBlock(tree->BClusters)) bin_cluster; drun(bcs++); if(oldCluster != NULL) { if(PUSHDOWN) { oldCluster->affected = DELETED; if(isRoot(oldCluster)) insertCluster(oldCluster,rootList); } else { freeVertexCluster(oldCluster,tree); } } thisNode->vertex->cl = cl; deprintf("Setting up binary cluster %p\n",cl); cl->id = thisNode->nId; cl->height = thisNode->height; // Make children cluster points to thisNode for(i = 0; i < MAX_DEGREE; i++) { cll = (cluster *) GET_CL(thisNode->scars[i].cl); if(cll) { cll->parent = cl; if(i == thisNode->left || i == thisNode->right) { cl->binaryCl[j] = (bin_cluster *) thisNode->scars[i].cl; j++; } else { cl->unaryCl[k] = (unary_cluster *) thisNode->scars[i].cl; k++; } } } for(k=k;k<MAX_DEGREE-2;k++) { cl->unaryCl[k] = NULL; } // Make node data cluster points to this node cll = thisNode->data; cll->parent = cl; cl->child = cll; }
void PSL1GHT_InitModes(_THIS) { deprintf(1, "+PSL1GHT_InitModes()\n"); SDL_DisplayMode mode; PSL1GHT_DisplayModeData *modedata; videoState state; modedata = (PSL1GHT_DisplayModeData *) SDL_malloc(sizeof(*modedata)); if (!modedata) { return; } assert(videoGetState(0, 0, &state) == 0); // Get the state of the display assert(state.state == 0); // Make sure display is enabled // Get the current resolution videoResolution res; assert(videoGetResolution(state.displayMode.resolution, &res) == 0); /* Setting up the DisplayMode based on current settings */ mode.format = SDL_PIXELFORMAT_ARGB8888; mode.refresh_rate = 0; mode.w = res.width; mode.h = res.height; modedata->vconfig.resolution = state.displayMode.resolution; modedata->vconfig.format = VIDEO_BUFFER_FORMAT_XRGB; modedata->vconfig.pitch = res.width * 4; mode.driverdata = modedata; /* Setup the display to it's default mode */ assert(videoConfigure(0, &modedata->vconfig, NULL, 1) == 0); // Wait until RSX is ready do{ SDL_Delay(10); assert( videoGetState(0, 0, &state) == 0); }while ( state.state == 3); /* Set display's videomode and add it */ SDL_AddBasicVideoDisplay(&mode); deprintf(1, "-PSL1GHT_InitModes()\n"); }
void PSL1GHT_VideoQuit(_THIS) { deprintf (1, "PSL1GHT_VideoQuit()\n"); PSL1GHT_QuitModes(_this); PSL1GHT_QuitSysEvent(_this); SDL_free( _this->driverdata); }
void SPE_RunContext(void *thread_argp) { spu_data_t *args = (spu_data_t *) thread_argp; deprintf(3, "[PS3->SPU] void* argp=0x%x\n", (unsigned int)args->argp); deprintf(2, "[PS3->SPU] Run SPE program: %s\n", args->program_name); if (spe_context_run (args->ctx, &args->entry, 0, (void *)args->argp, NULL, NULL) < 0) { deprintf(2, "[PS3->SPU] Failed running SPE context: %s\n", args->program_name); SDL_SetError("[PS3->SPU] Failed running SPE context: %s", args->program_name); exit(1); } pthread_exit(NULL); }