void TestMemory() { register unsigned char* i; PutString("TESTING MEMORY A", 1, 1); _SimUnprotect(0x4000, 0x5fff); for(i=(char*)0x4000; i<(char*)0xEEEA; i++) { *i=0xAA; } for(i=(char*)0x4000; i<(char*)0xEEEA; i++) { if(*i!=0xAA) { PutString("BAD MEMORY", 1, 1); Halt("BAD MEMORY"); } } PutString("TESTING MEMORY B", 2, 1); _SimUnprotect(0x4000, 0x5fff); for(i=(char*)0x4000; i<(char*)0xEEEA; i++) { *i=(~0xAA); } for(i=(char*)0x4000; i<(char*)0xEEEA; i++) { if(*i!=(~0xAA)) Halt("BAD MEMORY"); } PutString("MEMORY TEST COMPLETE", 3, 1); _SimUnprotect(0x4000, 0x5fff); for(i=(char*)0x4000; i<(char*)0xEEEA; i++) { *i=0; } _SimPrintString("Memory test completed\n"); }
int main() { SpaceId kid; int joinval; char *args[1]; args[0] = (char *)0; print("PARENT exists\n"); if ((kid=Fork()) == 0) { Exec("deepkid1", args); print("ERROR: exec failed\n"); Halt(); } if(kid==-1){Halt();} print("PARENT after fork/exec; kid pid is "); printd((int)kid, ConsoleOutput); print("\n"); print("PARENT about to Join kid\n"); joinval = Join(kid); print(">>PARENT off Join with value of "); printd(joinval, ConsoleOutput); print("\n"); Exit(10); Halt(); /* not reached */ }
// This is our PRAM program // After each case x label, you can put an instruction void step(int pc, int i, int * x, int * y, int * z) { int debug=0; int writecount=0; // printf("%d %d %d %d %d\n",pc, i, *x, *y, *z); // i is the processor number // *x, *y and *z are temporary registers switch(pc) { case 0: *z = 0; break; // Init N <= g < 2N-1 and 2N <= p < 3N - 1 and 3N <= z <= 4N-1 case 1: *y = Read(i+N); break; case 2: *x = Read(i); break; case 3: *x = *x + *y; break; case 4: Write(i,((*x)%10)); break; case 5: Write(i+N,((*x)>9)); break; case 6: Write(i+2*N,(*x==9)); // p break; case 7: Write(3*N+i, 0); break; // Prefix sum the g case 8: JumpIf(13,i<(int)pow(2,Read(3*N+i))); break; case 9: *x = Read(i+N) /* g */ || ( Read(i+2*N) /* p */ && Read(i+N-(int)pow(2,Read(3*N+i))) /*g' */ ); break; case 10: Write(i+N,*x); //g break; case 11: *x = Read(i+2*N) && Read(i+2*N-(int)pow(2,Read(3*N+i))); break; case 12: Write(i+2*N,*x); break; case 13: Write(3*N+i,Read(3*N+i)+1); // step increment break; case 14: JumpIf(8,Read(3*N+i)<(int)log2(N)) ; break; // Sum case 15: JumpIf(19,i==0); break; case 16: *x = Read(i); break; case 17: *y = Read(i+N-1) || Read(i+2*N-1); break; case 18: Write(i,(*x + *y)%10); break; case 19: Halt(); break; default: Halt(); } }
void _InterruptService() { register short i; ExchangeRegs(); GetStackPointerASM(_UserSP); SaveIndexes(); if(ControlRequests<0) Halt("NEGATIVE CONTROLREQUESTS"); if(!IsMultitasking()) Halt("INTERRUPT IN KERNEL MODE"); ControlRequests++; Tick(); for(i=0; i<InterruptVectorCount; i++) { (InterruptVector[i])(); } Scheduler(UserSP); Halt("OUT OF REACH"); }
int main() { int i; OpenFileId f0, f1; Create( "test1_f0" ); Create( "test1_f1" ); f0 = Open( "test1_f0" ); f1 = Open( "test1_f1" ); Write( "Test1: This is file 0\n", 22, f0 ); Write( "Test1: This is file 1\n", 22, f1 ); for( i = 0; i < 256; ++i ) usr_buffer_0[i] = 'A'; Write( usr_buffer_0, 128, f0 ); /* reset file pointer of f0 to the starting position */ Close( f0 ); f0 = Open( "test1_f0" ); Read( usr_buffer_1, 128, f0 ); Write( usr_buffer_1, 128, 1 ); // adding this allows the second write to work Write( usr_buffer_1, 128, f1 ); Close( f0 ); Close( f1 ); Halt(0); }
int main() { // Escribimos un texto indicativo sobre la consola. char *writeStr = "Ingrese un texto:\n"; Write(writeStr, 18, ConsoleOutput); // Leemos caracteres desde la consola hasta encontrar el "\n". char readStr[1024], tmpChar; int i = 0; do { Read(&tmpChar, 1, ConsoleInput); readStr[i] = tmpChar; i++; } while (tmpChar != '\n'); // Escribimos los caracteres ingresados en la consola. writeStr = "Usted ingreso:\n"; Write(writeStr, 16, ConsoleOutput); Write(readStr, i, ConsoleOutput); // Realizamos una llamada a halt para finalizar Nachos. Halt(); }
void CTestSignals::KeyComplete(TKeyCode aKey) { switch (aKey) { case EKeyEscape: Halt(); break; default: switch (iState) { case EAllOff: DoSignals(ERtsOn); break; case ERtsOn: DoSignals(EDtrOn); break; case EDtrOn: DoSignals(EAllOn); break; case EAllOn: DoSignals(EAllOff); break; default: break; } } }
void CTestRandTerm::KeyComplete(TKeyCode aKey) { if (iTrace) Test.Printf(_L("CTestRandTerm::KeyComplete(%d)\r\n"), aKey); switch ((TInt)aKey) { case EKeyEscape: Halt(); break; case 'd': case 'D': Debug(); break; case 'q': case 'Q': iTrace = 0; break; case 'v': case 'V': iTrace = 1; break; default: break; } }
void CTestXonXoff::KeyComplete(TKeyCode aKey) { if (iTrace) Test.Printf(_L("CTestXonXoff::KeyComplete(%d)\r\n"), aKey); switch ((TInt)aKey) { case EKeyEscape: Halt(); break; case 'd': case 'D': Test.Printf(_L("\r\n")); Debug(); break; case 'q': case 'Q': iTrace = 0; break; case 'v': case 'V': iTrace = 1; break; case 's': case 'S': Test.Printf(_L("\r\n")); Test.Printf(_L("Keyboard : %08x, %d\r\n"), iKeyboard->iStatus.Int(), iKeyboard->IsActive()); Test.Printf(_L("Timer : %08x, %d\r\n"), iTimer->iStatus.Int(), iTimer->IsActive()); Test.Printf(_L("Reader : %08x, %d\r\n"), iReader->iStatus.Int(), iReader->IsActive()); Test.Printf(_L("Writer : %08x, %d\r\n"), iWriter->iStatus.Int(), iWriter->IsActive()); break; default: break; } }
int main() { Halt(); /* not reached */ }
/* A kernel magic function that is only used for getting kernel context for newbie */ KernelContext *init_newbie_kernel(KernelContext *kernel_context, void *_prev_pcb, void *_next_pcb){ pcb_t *next_proc = (pcb_t *) _next_pcb; //log_info("First time to init PID(%d) kernel stack!", next_proc->pid); if(next_proc->kernel_stack_pages == NULL) { log_err("Init kernel stack fail, pcb->kernel_stack_pages not malloc yet"); Halt(); } next_proc->kernel_context = *kernel_context; int rc = alloc_frame_and_copy(next_proc->kernel_stack_pages, kernel_page_table, GET_PAGE_NUMBER(KERNEL_STACK_BASE), GET_PAGE_NUMBER(KERNEL_STACK_LIMIT), kernel_memory.swap_addr); if(rc) { log_err("PID(%d) kernel stack cannot init", next_proc->pid); return NULL; } next_proc->init_done = 1; //print_page_table(kernel_page_table, 120, GET_PAGE_NUMBER(VMEM_0_LIMIT)); //print_page_table(next_proc->kernel_stack_pages, 0, 2); //log_info("First time to init PID(%d) kernel stack done", next_proc->pid); return kernel_context; }
int main() { SpaceId kid; int joinval; char *args[2]; args[0] = "huge"; args[1] = (char *)0; if ((kid = Fork()) == 0) Exec("huge",args); prints("PARENT after foprk/exec; kid pid is ", ConsoleOutput); printd((int)kid, ConsoleOutput); prints("\n", ConsoleOutput); prints("PARENT about to Join kid\n", ConsoleOutput); joinval = Join(kid); prints("PARENT off Join with value of ", ConsoleOutput); printd(joinval, ConsoleOutput); prints("\n", ConsoleOutput); Halt(); /* not reached */ }
// Begin executing the specified proc. // NOTE: place the current proc into the correct queue before calling void SwitchToProc(PCB *next_proc, UserContext *user_context) { TracePrintf(TRACE_LEVEL_FUNCTION_INFO, ">>> SwitchToProc()\n"); assert(user_context); assert(next_proc); // Save current user state current_proc->user_context = *user_context; TracePrintf(TRACE_LEVEL_DETAIL_INFO, "Loading next proc context into %p\n", user_context); TracePrintf(TRACE_LEVEL_DETAIL_INFO, "Loading next proc PID: %d\n", next_proc->pid); *user_context = next_proc->user_context; // Set the TLB registers for the region 1 page table. WriteRegister(REG_PTBR1, (unsigned int) next_proc->region_1_page_table); WriteRegister(REG_TLB_FLUSH, TLB_FLUSH_1); PCB *old_proc = current_proc; current_proc = next_proc; int rc = KernelContextSwitch(&SaveKernelContextAndSwitch, old_proc, next_proc); if (SUCCESS == rc) { TracePrintf(TRACE_LEVEL_DETAIL_INFO, "Succesfully switched kernel context!\n"); } else { TracePrintf(TRACE_LEVEL_NON_TERMINAL_PROBLEM, "Failed to save kernel context!\n"); char *err_str = calloc(TERMINAL_MAX_LINE, sizeof(char)); sprintf(err_str, "KernelContextSwitch failed!!! HALTING!!!\n", current_proc->pid); KernelTtyWriteInternal(0, err_str, strnlen(err_str, TERMINAL_MAX_LINE), user_context); free(err_str); Halt(); } // Restore user state of new current process *user_context = current_proc->user_context; TracePrintf(TRACE_LEVEL_FUNCTION_INFO, "<<< SwitchToProc()\n"); }
Nav2::~Nav2(){ coretracefunc(); Halt(); WaitNavigate2(); coreprintln("Halt and WaitNavigate2 completed.."); delete[] m_globalData->m_writable_files_path; delete[] m_globalData->m_readonly_files_path; delete m_errorTable; delete mainlog; delete m_globalData->m_logmaster; delete m_globalData; #ifdef __SYMBIAN32__ delete m_archGlobalData->m_timerThread; if(m_archGlobalData->m_socketServ){ m_archGlobalData->m_socketServ->Close(); delete m_archGlobalData->m_socketServ; m_archGlobalData->m_socketServ=NULL; } delete m_archGlobalData; deleteTlsGlobalData(m_tlsGlobalData, m_tlsGlobalDataId); #endif //delete m_audioSyntax; - owned by AudioCtrl... }
void NewContext(int* SP) { // SP for next task to go (arg #1) goes into HL SP; FunctionArgToReg(H, L); // Restores usermode status SetStackPointerASM(_OldSP); ExchangeRegs(); ReloadIndexes(); SaveContext(); // Switches to the process with stack in SP ExchangeRegs(); GetStackPointerASM(_TempSP); SetStackPointerREG(HL); *CurrentSP=TempSP; ExchangeRegs(); LoadContext(); if(ControlRequests==0) Halt("ISR IN USER MODE"); ControlRequests--; IntsOn(); ImmediateReturn(); }
int main(int argc, char **argv) { int i, joinval, tmp; SpaceId kid; char *args[1]; args[0] = (char *)0; for (i=0; i<100000; i++) tmp++; /* loop to delay kid initially */ if ((kid=Fork()) == 0) { Exec("deepkid2", args); print("ERROR: exec failed in kid\n"); Exit(100); } print("KID1 after exec; kid1 pid is "); printd((int)kid, ConsoleOutput); print("\n"); print("KID1 about to Join kid2\n"); joinval = Join(kid); print("KID1 off Join with value of "); printd(joinval, ConsoleOutput); print("\n"); Exit(1); /* Should not get past here */ print("ERROR: KID1 after Exit()\n"); Halt(); /* not reached */ }
int main() { SpaceId kid; int joinval; prints("PARENT exists\n", ConsoleOutput); kid = Fork(); if (kid != 0) { prints("PARENT after fork; kid pid is ", ConsoleOutput); printd((int)kid, ConsoleOutput); prints("\n", ConsoleOutput); joinval = Join(kid); prints("PARENT off Join with value of ", ConsoleOutput); printd(joinval, ConsoleOutput); prints("\n", ConsoleOutput); Halt(); /* not reached */ } else Exec("kid"); }
int main() { SpaceId kid; int joinval; prints("PARENT exists\n", ConsoleOutput); kid = Fork(); if (kid != 0) { prints("PARENT after fork; kid pid is ", ConsoleOutput); printd((int)kid, ConsoleOutput); prints("\n", ConsoleOutput); joinval = Join(kid); prints("PARENT off Join with value of ", ConsoleOutput); printd(joinval, ConsoleOutput); prints("\n", ConsoleOutput); Exit(56); Halt(); /* not reached */ } else { prints("KID running, about to Exit()\n", ConsoleOutput); /* You may want to put some real code here */ Exit(17); } }
static void Exit(void) { if (!Halt()) { CommOS_StopIO(); } }
int main() { int i, j, k; prints("Starting matmult\n", ConsoleOutput); for (i = 0; i < Dim; i++) /* first initialize the matrices */ for (j = 0; j < Dim; j++) { A[i][j] = i; B[i][j] = j; C[i][j] = 0; } prints("Initialization Complete\n", ConsoleOutput); for (i = 0; i < Dim; i++) { /* then multiply them together */ prints("i = ", ConsoleOutput); printd(i, ConsoleOutput); prints("\n", ConsoleOutput); for (j = 0; j < Dim; j++) for (k = 0; k < Dim; k++) C[i][j] += A[i][k] * B[k][j]; } prints("C[", ConsoleOutput); printd(Dim-1, ConsoleOutput); prints(",", ConsoleOutput); printd(Dim-1, ConsoleOutput); prints("] = ", ConsoleOutput); printd(C[Dim-1][Dim-1], ConsoleOutput); prints("\n", ConsoleOutput); Exit(1); Halt(); /* and then we're done */ }
int main() { PutString("Files opened...\n"); ForkExec("userpages1"); PutChar('\n'); ForkExec("userpages2"); PutChar('\n'); ForkExec("userpages1"); PutChar('\n'); ForkExec("userpages2"); PutChar('\n'); ForkExec("userpages1"); PutChar('\n'); ForkExec("userpages2"); PutChar('\n'); ForkExec("userpages1"); PutChar('\n'); ForkExec("userpages2"); PutChar('\n'); ForkExec("userpages1"); PutChar('\n'); ForkExec("userpages2"); PutChar('\n'); ForkExec("userpages1"); PutChar('\n'); ForkExec("userpages2"); PutChar('\n'); PutString("\nExiting...\n"); Halt(); }
void KmxController::CycleStart() { if (interpreting) { Halt(); } else { interpret(2, current_gcode_file_ , currentLine, -1, true); } }
/* Wrapper of kernel context switch * * @param next_proc: the process to be switched in * @param user_context: current user context */ void context_switch_to(pcb_t *next_proc, UserContext *user_context) { int rc = 0; rc = KernelContextSwitch(&kernel_context_switch, running_proc, next_proc); if(rc) { log_err("Failed to execute magic function!"); Halt(); } }
int main () { Halt (); /* not reached */ return 0; }
void Task2() { while(1) { if(!IsMultitasking()) { Halt("INTS DISABLED PRC2"); } ConsoleWrite("2"); _SimPrintString("2"); } }
void Resume() { if(ControlRequests>0) { ControlRequests--; if(ControlRequests==0) { UserMode(); } } else { Halt("RESUME WITHOUT PAUSE"); } }
/* Used for special processes that is not forked to init kernel context, * meaning this process is manually created by Yalnix */ void init_process_kernel(pcb_t *proc) { int rc = 0; rc = KernelContextSwitch(&init_newbie_kernel, proc, proc); if(rc) { log_err("Failed to execute magic function!"); Halt(); } //log_info("Init PID(%d) kernel stack done", proc->pid); }
int main() { int result; result = Add(42, 23); Halt(); /* not reached */ }
int main() { void (*func)(); func = &printfork; Fork(func); Sleep(10000000); /*Exit(0);*/ Halt(); }
/* * write.c * * Created on: 2012-11-18 * Author: rye */ int main() { //Test Create int fd; int readSize; Create("TestSysCall"); fd = Open("TestSysCall"); Write("Test my system call.",21,fd); Close(fd); Halt(); }