s64 SysCalls::DoSyscall(u32 code) { if(code < 0x400) { if(sc_table[code]) { (*sc_table[code])(); return SC_ARGS_1; } //TODO: remove this switch(code) { //process case 2: return lv2ProcessWaitForChild(CPU); case 4: return lv2ProcessGetStatus(CPU); case 5: return lv2ProcessDetachChild(CPU); case 12: return lv2ProcessGetNumberOfObject(CPU); case 13: return lv2ProcessGetId(CPU); case 18: return lv2ProcessGetPpid(CPU); case 19: return lv2ProcessKill(CPU); case 23: return lv2ProcessWaitForChild2(CPU); case 25: return lv2ProcessGetSdkVersion(CPU); //timer case 141: case 142: Sleep(SC_ARGS_1 / (1000 * 1000)); return 0; //tty case 988: ConLog.Warning("SysCall 988! r3: 0x%llx, r4: 0x%llx, pc: 0x%llx", CPU.GPR[3], CPU.GPR[4], CPU.PC); return 0; case 999: dump_enable = !dump_enable; ConLog.Warning("Dump %s", dump_enable ? "enabled" : "disabled"); return 0; } ConLog.Error("Unknown syscall: %d - %08x", code, code); return 0; } if(CallFunc(code)) return SC_ARGS_1; //ConLog.Error("Unknown function 0x%08x", code); //return 0; //TODO: remove this return DoFunc(code); }
void SysCalls::DoSyscall(u32 code) { if(code < 1024) { (*sc_table[code])(); return; } if(CallFunc(code)) { return; } //ConLog.Error("Unknown function 0x%08x", code); //return 0; //TODO: remove this declCPU(); RESULT(DoFunc(code)); }
void Run() { int frontSSN; int lineType; while(true) { Acquire(CashierLock); bribeLineCount = DoFunc(GetMV, LineCount, 3, Cashier, line, Bribe, BLANK); lineCount = DoFunc(GetMV, LineCount, 3, Cashier, line, Regular, BLANK); if(bribeLineCount > 0) { Write("Cashier Clerk ", 18, ConsoleOutput); IntPrint(line); Write(" has received $500 from Customer\n ", 33, ConsoleOutput); lineType = Bribe; Signal(CashierBribeCVs[line], CashierLock); DoFunc(SetMV, ClerkState, 3, Cashier, line, Busy, BLANK); } else if(lineCount > 0) { Write("Cashier Clerk ", 18, ConsoleOutput); IntPrint(line); Write(" has signalled a Customer to come to the counter\n", 49, ConsoleOutput); lineType = Regular; Signal(CashierLineCVs[line], CashierLock); DoFunc(SetMV, ClerkState, 3, Cashier, line, Busy, BLANK); } else { DoFunc(SetMV, ClerkState, 3, Cashier, line, Break, BLANK); } Acquire(CashierLineLocks[line]); Release(CashierLock); Wait(CashierLineCVs[line], CashierLineLocks[line]); if(lineType == Bribe) { frontSSN = DoFunc(GetMV, FrontOfLine, 3, Cashier, line, Bribe, BLANK); } else { frontSSN = DoFunc(GetMV, FrontOfLine, 3, Cashier, line, Regular, BLANK); } Write("Customer ", 9, ConsoleOutput); IntPrint(frontSSN); Write(" has given SSN ", 15, ConsoleOutput); IntPrint(frontSSN); Write(" to Applicatoin Clerk ", 22, ConsoleOutput); IntPrint(line); Write("\n", 1, ConsoleOutput); Signal(CashierLineCVs[line], CashierLineLocks[line]); Wait(CashierLineCVs[line], CashierLineLocks[line]); Release(CashierLineLocks[line]); } }