Пример #1
0
void
rm_sysinit(void *arg)
{
	struct rm_args *args = arg;

	rm_init(args->ra_rm, args->ra_desc);
}
Пример #2
0
/**
 * \brief Entry point.
 * \param argc The number of input parameters.
 * \param argv The input parameters.
 */
int main(int argc, char *argv[]) {

	/* the resource manager must be initialized before any
	 * further actions are implemented */
	rm_init(&resource_mgr);

	if (process_options(argc, argv) == 1) {
		rm_cleanup_resources(&resource_mgr);
		exit(EXIT_FAILURE);
	}

	if (cc_options.print_only_errors != 1) {
		printf("Input: %s\n", cc_options.input_file);
		printf("Output: %s\n", cc_options.output_file);
		printf("IR: %s\n", cc_options.ir_file);
	}

	yyin = fopen(cc_options.input_file, "r");
	if (!yyin) {
		fprintf(stderr,
				"Input file could not be opened for reading. Maybe, file does not exist?");
	} else {
		setSymbolTable(createSymbol());
		yyparse();
		fclose(yyin);
		irCode_t* ircode = NULL;

		if (cc_options.ir_file != NULL) {
			FILE *irFile;
			irFile = fopen(cc_options.ir_file, "w+");

			// Test symbolTable
			print_symTab(irFile);

			// get ir code and print it into irFile
			struct func_t *func, *tmp;
			HASH_ITER(hh, getSymbolTable()->symFunc, func, tmp) {
				if (func->symbol != NULL) {
					fprintf(irFile, "Function %s:\n", func->id);
					printIRCode(irFile, func->symbol->ircode);
				}
			}

			fclose(irFile);
		}

		yyout = fopen(cc_options.output_file, "w+");
		if (!yyout) {
			fprintf(stderr,
					"Output file could not be opened for writing. Maybe, file does not exist?");
		} else {
			int ret = mips32gen(yyout, ircode, getSymbolTable());
			if (ret != 0) {
				fprintf(stderr, "Error generating mips32 code with code: %d\n",
						ret);
			}
			fclose(yyout);
		}
	}
Пример #3
0
int main() {

    if (-1==rm_init (read_h, write_h, NULL, NULL, 4, 4))
    {
        printf ("rm_init() failed!\n");
        return 0;
    }

    printf("Logging initial rm state (res=%d)\n", rm_make_dump_file("dump_init.txt"));

    return 0;
}
Пример #4
0
/**
 * \brief Entry point.
 * \param argc The number of input parameters.
 * \param argv The input parameters.
 * \author Niklas Assmann
 */
int main(int argc, char *argv[]) {
	/* the resource manager must be initialized before any
	 * further actions are implemented */

	rm_init(&resource_mgr);

	if (process_options(argc, argv) == 1) {
		rm_cleanup_resources(&resource_mgr);
		exit(EXIT_FAILURE);
	}

	printf("Input: %s\n", cc_options.input_file);
	printf("Output: %s\n", cc_options.output_file);
	printf("IR: %s\n", cc_options.ir_file);

	// open the source file
	FILE *myfile = fopen(cc_options.input_file, "r");

	// make sure it can be opened
	if (!myfile) {
		printf("ERROR! Could not open input file.\n");
		return(-1);
	}

	// set flex to read from the source file instead of defaulting to STDIN:
	yyin = myfile;
	// parse the input file
	do {
		yyparse();
	} while (!feof(yyin));

	if (cc_options.print_ir){

		FILE *ir_file = fopen(cc_options.ir_file, "w");
		print_ir_code_to_file(ir_file);	//print the final ir_code to this file
		fclose(ir_file);

		debug_printSourceCode();		//debug function for printing the source file
		debug_printSymbolTable();		//debug function for printing the symbol table
		debug_print_all_codes();		//debug function for printing the intermediate code
	}

	// close the source file
	fclose(myfile);

	rm_cleanup_resources(&resource_mgr);

	return(0);
}
Пример #5
0
// ---------------------------------------------------------------------
//  _dc_init_rm
// ---------------------------------------------------------------------
int _dc_init_rm() {

    // patch and size tables
    void* patch_table[rm_patch_num][rm_size_num] = { { NULL } };
    size_t size_table[rm_patch_num][rm_size_num] = { { 0 } };

    // init rm patch table
    _dc_init_patch_table(patch_table, size_table);
    
    // initialize rm
    rm_init(NULL, NULL, patch_table, size_table, 
        sizeof(void*), DC_REACTIVE_CELL_SIZE);

    return 0;
}
Пример #6
0
/**
 * \brief Entry point.
 * \param argc The number of input parameters.
 * \param argv The input parameters.
 */
int main(int argc, char *argv[]) {
	/* the resource manager must be initialized before any
	 * further actions are implemented */
	rm_init(&resource_mgr);

	if (process_options(argc, argv) == 1) {
		rm_cleanup_resources(&resource_mgr);
		exit(EXIT_FAILURE);
	}
	printf("Input: %s\n", cc_options.input_file);
	printf("Output: %s\n", cc_options.output_file);
	printf("IR: %s\n", cc_options.ir_file);

	yyin = fopen(cc_options.input_file, "r");

	if (!yyin) {
		printf("FAIL");
		exit(1);
	}

	//  yyparse();

	do {
		yyparse();
	} while (!feof(yyin));

	fclose(yyin);
	printallstart(cc_options.output_file);
	if (cc_options.print_ir == 1) {
		FILE * ir_file = fopen(cc_options.ir_file, "w");
		ir_set_file(ir_file);
		generate_ir_code();
		fclose(ir_file);
	}

	rm_cleanup_resources(&resource_mgr);
	return 0;
}
Пример #7
0
/**
 * \brief Entry point.
 * \param argc The number of input parameters.
 * \param argv The input parameters.
 */
int main (int argc, char *argv[]) {
	extern FILE* yyin;
	FILE* ir_output_file;
	//extern symtab_entry *symtab;
	//extern symtab_entry *current_symtab;

	/* the resource manager must be initialized before any
   * further actions are implemented */
  rm_init(&resource_mgr);

  if (process_options(argc, argv) == 1) {
    rm_cleanup_resources(&resource_mgr);
    exit(EXIT_FAILURE);
  }

  printf("Input: %s\n", cc_options.input_file);
  printf("Output: %s\n", cc_options.output_file);
  printf("IR: %s\n", cc_options.ir_file);

  //Set Input file and Start parsing
  yyin = fopen(cc_options.input_file,"r");
  
  //Globals
  symtab = NULL;
  current_symtab = NULL;
  pointer_to_called_function = NULL;
  MAIN_FUNCTION_FLAG = 0;
  GLOBAL_DECLARATION_FLAG = 0;
  help_var_counter = 0;
  help_label_counter = 0;
  global_help_var = (char *) malloc(sizeof(char)*15);
  global_help_label = (char *) malloc(sizeof(char)*15);
  init(&GLOBAL_HELP_STACK);
  intermediate_code = NULL;
  offset = 0;
  global_offset = 0;
  
  //Start parsing
  yyparse();
  
  //Output after Parsing
  //Symboltable
  printf("Symboltable:\n\n");
  print_symtab();
  
  //Intermediatecode
  if(intermediate_code != NULL){
  remove_nop_statements_from_ircode(intermediate_code);
  printf("INTERMEDIATE CODE:\n\n");
  print_ircode(intermediate_code);
 // print_basic_blocks(generate_basic_blocks(intermediate_code));
  }

  //Final Codegen
  if(intermediate_code != NULL){
  init_general_registers();
  show_general_registers();
  generate_final_code(intermediate_code);
  show_general_registers();


  }

   

  if(!MAIN_FUNCTION_FLAG)
  	printf("FATAL COMPILER ERROR no main function defined!\n");

  //Cleanup resources
  free(global_help_var);
  rm_cleanup_resources(&resource_mgr);
  fclose(yyin);
  return 0;
}
Пример #8
0
int main() {
	size_t shadow_rec_size = 32;
	size_t shadow_wordsize = 4;
	
	int* prot_array;
	int* unprot_array;
	
	double prot_write_times;
	double prot_read_times;
	double unprot_write_times;
	double unprot_read_times;
	
	struct timeval tvBeginProtWrite, tvEndProtWrite;
	struct timeval tvBeginProtRead, tvEndProtRead;
	struct timeval tvBeginUnprotWrite, tvEndUnprotWrite;
	struct timeval tvBeginUnprotRead, tvEndUnprotRead;
	
	int i, value;
	
	printf("MAIN - start\n");
	
	/*initializes rm*/
	if (rm_init(read_handler, write_handler, NULL, NULL, shadow_rec_size, shadow_wordsize) == -1) {
		printf("main: rm_init error!!\n");
		return -1;
	}
	
	printf("N is %d\n", N);
	
	/*allocates protected mem*/
	prot_array = (int*)rm_malloc(N * sizeof(int));
	if(prot_array == NULL)
		printf("[main] ERROR: Could not allocate protected mem!\n");
	
	/*allocates unprotected mem*/
	unprot_array = (int*)malloc(N * sizeof(int));
	if(unprot_array == NULL)
		printf("[main] ERROR: Could not allocate unprotected mem!\n");
	
	
	/* PROTECTED WRITE LOOP */
	printf("Protected write loop\n");
	/*fetches initial time*/
	gettimeofday(&tvBeginProtWrite, NULL);
	/*performs N writes to prot mem*/
	for(i=0; i<N; i++) {
		/*performs access*/
		*(prot_array + i) = i;
	}
	/*fetches final time*/
	gettimeofday(&tvEndProtWrite, NULL);
	prot_write_times = tvEndProtWrite.tv_sec + (tvEndProtWrite.tv_usec*0.000001)
			-tvBeginProtWrite.tv_sec - (tvBeginProtWrite.tv_usec*0.000001);
	
	/* UNPROTECTED WRITE LOOP */
	printf("Unprotected write loop\n");
	/*fetches initial time*/
	gettimeofday(&tvBeginUnprotWrite, NULL);
	/*performs N writes to unprot mem*/
	for(i=0; i<N; i++) {
		/*performs access*/
		*(unprot_array + i) = i;
	}
	/*fetches final time*/
	gettimeofday(&tvEndUnprotWrite, NULL);
	unprot_write_times = tvEndUnprotWrite.tv_sec + (tvEndUnprotWrite.tv_usec*0.000001)
			-tvBeginUnprotWrite.tv_sec - (tvBeginUnprotWrite.tv_usec*0.000001);
	
	/* PROTECTED READ LOOP */
	printf("Protected read loop\n");
	/*fetches initial time*/
	gettimeofday(&tvBeginProtRead, NULL);
	/*performs N reads from prot mem*/
	for(i=0; i<N; i++) {
		/*performs access*/
		value = *(prot_array + i);
	}
	/*fetches final time*/
	gettimeofday(&tvEndProtRead, NULL);
	prot_read_times = tvEndProtRead.tv_sec + (tvEndProtRead.tv_usec*0.000001)
			-tvBeginProtRead.tv_sec - (tvBeginProtRead.tv_usec*0.000001);
	
	/* UNPROTECTED READ LOOP */
	printf("Unprotected read loop\n");
	/*fetches initial time*/
	gettimeofday(&tvBeginUnprotRead, NULL);
	/*performs N reads from unprot mem*/
	for(i=0; i<N; i++) {
		/*performs access*/
		value = *(unprot_array + i);
	}
	/*fetches final time*/
	gettimeofday(&tvEndUnprotRead, NULL);
	unprot_read_times = tvEndUnprotRead.tv_sec + (tvEndUnprotRead.tv_usec*0.000001)
			-tvBeginUnprotRead.tv_sec - (tvBeginUnprotRead.tv_usec*0.000001);
	
	
	/*prints debug controls*/
	printf("\n*** DEBUG ***\n");
	printf("write_num = %d\n", write_num);
	printf("read_num = %d\n", read_num);
	printf("*(prot_array) = %d\n", *(prot_array));
	printf("*(prot_array + 5) = %d\n", *(prot_array + 5));
	printf("*(prot_array + N - 1) = %d\n", *(prot_array + N - 1));
	
	/*prints results*/
	printf("\n*** RESULTS ***\n");
	printf("Seconds taken for %d protected writes: %f\n", N, prot_write_times);
	printf("Seconds taken for %d unprotected writes: %f\n", N, unprot_write_times);
	printf("Seconds taken for %d protected reads: %f\n", N, prot_read_times);
	printf("Seconds taken for %d unprotected reads: %f\n", N, unprot_read_times);
	printf("Ratio between prot and unprot writes: %f\n", prot_write_times/unprot_write_times);
	printf("Ratio between prot and unprot reads: %f\n", prot_read_times/unprot_read_times);
	
	/*clean up*/
	rm_free(prot_array);
	free(unprot_array);
	
	printf("MAIN - end\n");
	
	return 0;
}
Пример #9
0
int main(int argc, char* argv[])
{
    HX_RESULT           retVal         = HXR_OK;
    FILE*               fp             = HXNULL;
    FILE*               fpOutYUV          = HXNULL;
    FILE*               fpOutAUD          = HXNULL;
    UINT32              i              = 0;
	UINT32              j              = 0;
    rmInfo rm_Info;
    char *pRa=HXNULL;
	UINT32 rvOut[5];//Y,U,V,W,H
    UINT32 raLen=0;
	U8 *pTemp;
	VocWorkStruct VocState;
	I8 skip;

    /* Check the arguments */
    if (argc != 3)
    {
        rm_printf("Usage: %s <rm_file> <yuv_file>\n", argv[0]);
        retVal         = HXR_FAIL;
        return retVal;
    }


    /* Open the input file */
    fp = fopen((const char*) argv[1], "rb");
    if (!fp)
    {
        rm_printf("Could not open %s for reading.\n", argv[1]);
        retVal         = HXR_FAIL;
        return retVal;
    }

    /* Open the output file */
    fpOutYUV = fopen((const char*) argv[2], "wb");
    if (!fpOutYUV)
    {
        rm_printf("Could not open %s for writing.\n", argv[2]);
        retVal         = HXR_FAIL;
        return retVal;
    }
    
    fpOutAUD = fopen("F://╡Бйтнд╪Ч//test.aac", "wb");
    if (!fpOutAUD)
    {
        rm_printf("Could not open test.aac for writing.\n");
        retVal         = HXR_FAIL;
        return retVal;
    }
    
	pRa=malloc(8*1024);

	retVal=rm_init(fp, &rm_Info);
	if(retVal != HXR_OK)
		return retVal;

	printf("duration=%d ms\n", rm_Info.rm_Duration);
	printf("num_stream=%d \n", rm_Info.rm_NumStream);
	printf("rv format=%x \n", rm_Info.rv_Format);
	printf("width=%d \n", rm_Info.rv_Width);
	printf("height=%d \n", rm_Info.rv_Height);
	printf("fps=%d \n", rm_Info.rv_Fps);
	
	printf("ra format=%x \n", rm_Info.ra_Format);
	printf("samplerate=%d \n", rm_Info.ra_SampleRate);
	printf("ra_BitsPerSample=%d \n", rm_Info.ra_BitsPerSample);
	printf("ra_NumChannels=%d \n", rm_Info.ra_NumChannels);

	for(i=0;i<300000;i++)
	{
#if 1
		if(i==0)
		{
#if 0
			raLen=rm_getAudioTempBufRemain();
		        raLen= rm_getAudioData(pRa, raLen);
			 if(raLen<=0)
			 {
			 	printf("rm rm_getAudioData err retVal=%d\n", raLen);
			 	//return raLen;
			 }
			 
			 fwrite(pRa, 1, raLen, fpOutAUD);
			    /* Display results */
		    	rm_printf( "Audio stream remain raLen=%d\n", raLen);
#endif		
			retVal=rm_seek(rm_Info.rm_Duration);//init seek table
			retVal=rm_seek(0);
			 if(retVal!=HXR_OK)
			 {
			 	printf("rm seek err retVal=%d\n", retVal);
			 	return retVal;
			 }
		}
		else if(i%8==0)
		{
#if 1
			UINT32 timestamp;

			timestamp=rm_getLastFrameTimeStamp();
			timestamp=rm_getNextKeyTimeStamp(timestamp+8000);
			rm_seek_video(timestamp);
			timestamp=rm_getKeyTimeStamp();
#endif
#if 0
			raLen=rm_getAudioTempBufRemain();
		        raLen= rm_getAudioData(pRa, raLen);
			 if(raLen<=0)
			 {
			 	printf("rm rm_getAudioData err retVal=%d\n", raLen);
			 	return raLen;
			 }
			 
			 fwrite(pRa, 1, raLen, fpOutAUD);
			    /* Display results */
		    	rm_printf( "Audio stream remain raLen=%d\n", raLen);
		    	
			retVal=rm_seek( 2000);
			 if(retVal!=HXR_OK)
			 {
			 	printf("rm seek err retVal=%d\n", retVal);
			 	return retVal;
			 }
#endif
		}
		else if(rm_getLastFrameTimeStamp()==4000)
		{
			UINT32 timestamp;
		//	timestamp=rm_getNextKeyTimeStamp(4000+26*40);
			//rm_seek_video(timestamp);
			//rm_seek(1840);
		}
#endif

		/*output yuv*/
#if 1
		VOC_WORK=0;
		VocState.pVOC_WORK=&VOC_WORK;
		VocState.vid_voc_isr=vid_voc_isr;

		skip=0;
		//if((i&0x3)==3)skip=1;
		retVal=rm_getOneFrameVideo(&rvOut, &VocState, skip);

		 if(retVal==HXR_OK)
		 {
			 //fwrite(rvOut[0], 1, rvOut[3]*rvOut[4]*3/2, fpOutYUV);
			 /*
			 fwrite(rvOut[0], 1, rvOut[3]*rvOut[4], fpOutYUV);
			 fwrite(rvOut[1], 1, rvOut[3]*rvOut[4]>>2, fpOutYUV);
			 fwrite(rvOut[2], 1, rvOut[3]*rvOut[4]>>2, fpOutYUV);
			 */
			 
			 pTemp=(U8*)rvOut[0];
			 for(j=0;j<rvOut[4];j++)
			 {
				fwrite(pTemp+ j*rvOut[3], 1, rvInfo.ulWidth, fpOutYUV);
			 }

			 pTemp=(U8*)rvOut[1];
			 for(j=0;j<(rvOut[4])>>1;j++)
			 {
				 fwrite(pTemp+ (j*rvOut[3]>>1), 1, rvInfo.ulWidth>>1, fpOutYUV);
			 }

			 pTemp=(U8*)rvOut[2];
			 for(j=0;j<(rvOut[4])>>1;j++)
			 {
				 fwrite(pTemp+ (j*rvOut[3]>>1), 1, rvInfo.ulWidth>>1, fpOutYUV);
			 }
			 
				/* Display results */
			rm_printf("RM: F in=%lu, F out=%lu rv_Timestamp_dis=%d\n",
					rvInfo.ulNumInputFrames, rvInfo.ulNumOutputFrames, rv_Timestamp_dis);
		}
		else if(retVal==HXR_SKIP_BFRAME)
Пример #10
0
int main() {
	size_t shadow_rec_size = 32;
	size_t shadow_wordsize = 4;
	
	printf("MAIN - start\n");
	
	if (rm_init(read_handler, write_handler, NULL, NULL, shadow_rec_size, shadow_wordsize) == -1) {
		printf("main: rm_init error!!\n");
		return -1;
	}
	
#if rm_DEBUG == 1
	if (rm_make_dump_file("dump1.txt") == -1) {
		printf("main: rm_make_dump_file error!!\n");
		return -1;
	}
#endif
	
#if rm_STAT == 1
	printf("\n\n\n*** STATS - start ***\n");
	printf("g_stats.patch_instr_number = %u\n", g_stats.patch_instr_number);
	printf("g_stats.cache_instr_number = %u\n", g_stats.cache_instr_number);
	printf("g_stats.BB_number = %u\n", g_stats.BB_number);
	printf("g_stats.BB_min_size = %u\n", g_stats.BB_min_size);
	printf("g_stats.BB_med_size = %u\n", g_stats.BB_med_size);
	printf("g_stats.BB_max_size = %u\n", g_stats.BB_max_size);
	printf("g_stats.BB_min_instr_number = %u\n", g_stats.BB_min_instr_number);
	printf("g_stats.BB_med_instr_number = %u\n", g_stats.BB_med_instr_number);
	printf("g_stats.BB_max_instr_number = %u\n", g_stats.BB_max_instr_number);
	printf("*** STATS - end ***\n");
#endif
	
	int* a;
	int b;
	a = (int*)rm_malloc(sizeof(int));
	printf("\n\n\n");
	printf("Puntatore a = %p\n", a);
	printf("Puntatore rm_get_inactive_ptr(a) = %p\n", rm_get_inactive_ptr(a));
	printf("rm_is_reactive(a) = %d\n", rm_is_reactive(a));
	printf("rm_is_reactive(rm_get_inactive_ptr(a)) = %d\n", rm_is_reactive(rm_get_inactive_ptr(a)));
	printf("rm_get_shadow_rec(a) = %p\n", rm_get_shadow_rec(a));
	
	printf("*** Scrittura ***\n");
	*a = 5;
	printf("*** Lettura ***\n");
	b = *a;
	printf("b = %d\n", b);
	
#if rm_DEBUG == 1
	if (rm_make_dump_file("dump2.txt") == -1) {
		printf("main: rm_make_dump_file error!!\n");
		return -1;
	}
#endif
	
	
	
	printf("MAIN - end\n");
	
	return 0;
}