示例#1
0
文件: Test.cpp 项目: mmanley/Antares
int main(int argc, char* argv[])
{
	const char* arg = argc >= 2 ? argv[1] : NULL;
	
	if (argc >= 3) {
		gPPDFile = argv[2];
	}
	
	if (enabled("scanner", arg)) {
		TestScanner();
	}
	if (enabled("parser", arg)) {
		TestParser();
	}
	if (enabled("ppd", arg)) {
		TestPPDParser(true);
	}
	if (enabled("header", arg)) {
		TestPPDParser(false);
	}
	if (enabled("ui", arg)) {
		TestExtractUI();
	}
	if (enabled("ppd-timing", arg)) {
		TestPPDParser(true, false);
	}
	if (enabled("header-timing", arg)) {
		TestPPDParser(false, false);
	}
	
	if (arg == NULL) {
		printArgs(argv[0]);
	}
}
示例#2
0
void osInit(int argc, char *argv[]) {
	void *PageTable = (void *) calloc(2, VIRTUAL_MEM_PAGES);
	INT32 i;
	MEMORY_MAPPED_IO mmio;

	//init Queues
	initPCBTable();
	initTimerQueue();
	initReadyQueue();
	initMessageTable();

  // Demonstrates how calling arguments are passed thru to here       

    printf( "Program called with %d arguments:", argc );
    for ( i = 0; i < argc; i++ )
        printf( " %s", argv[i] );
    printf( "\n" );
    printf( "Calling with argument 'sample' executes the sample program.\n" );
    // Here we check if a second argument is present on the command line.
    // If so, run in multiprocessor mode
    if ( argc > 2 ){
    	printf("Simulation is running as a MultProcessor\n\n");
		mmio.Mode = Z502SetProcessorNumber;
		mmio.Field1 = MAX_NUMBER_OF_PROCESSORS;
		mmio.Field2 = (long) 0;
		mmio.Field3 = (long) 0;
		mmio.Field4 = (long) 0;

		MEM_WRITE(Z502Processor, &mmio);   // Set the number of processors
    }
    else {
    	printf("Simulation is running as a UniProcessor\n");
    	printf("Add an 'M' to the command line to invoke multiprocessor operation.\n\n");
    }

	//          Setup so handlers will come to code in base.c   

	TO_VECTOR[TO_VECTOR_INT_HANDLER_ADDR ] = (void *) InterruptHandler;
	TO_VECTOR[TO_VECTOR_FAULT_HANDLER_ADDR ] = (void *) FaultHandler;
	TO_VECTOR[TO_VECTOR_TRAP_HANDLER_ADDR ] = (void *) svc;

	//  Determine if the switch was set, and if so go to demo routine. 

	PageTable = (void *) calloc(2, VIRTUAL_MEM_PAGES);
  	if ((argc > 1) && (strcmp(argv[1], "sample") == 0)) {
		mmio.Mode = Z502InitializeContext;
		mmio.Field1 = 0;
		mmio.Field2 = (long) SampleCode;
		mmio.Field3 = (long) PageTable;

		MEM_WRITE(Z502Context, &mmio);   // Start of Make Context Sequence
		mmio.Mode = Z502StartContext;
		// Field1 contains the value of the context returned in the last call
		mmio.Field2 = START_NEW_CONTEXT_AND_SUSPEND;
		MEM_WRITE(Z502Context, &mmio);     // Start up the context

 	} // End of handler for sample code - This routine should never return here

	/****************************Parse Input******************************/
	long *TestToRun;
	switch (argc){
		case 2:
			TestToRun = TestParser(argv[1]);
			ProcessorMode = Uniprocessor;
			break;
		case 3:
			TestToRun = TestParser(argv[1]);
			ProcessorMode = Multiprocessor;
			break;
		default:
			TestToRun = test1c;
			ProcessorMode = Uniprocessor;
			break;
	}
	/********************************************************************/

	long ErrorReturned;
	long newPID;
	struct Process_Control_Block *newPCB = OSCreateProcess((long*)"test1", TestToRun, (long*)3, (long*)&newPID, (long*)&ErrorReturned);
	if (newPCB != NULL) {
		enPCBTable(newPCB);
		enReadyQueue(newPCB);
	}
	Dispatcher();
}                                               // End of osInit