protected Action <CpuThreadState> CreateDelegate(HleModuleManager ModuleManager, HleModuleHost Module, uint NID, string ModuleImportName, string NIDName) { Action <CpuThreadState> Callback = null; if (Module != null) { Callback = Module.DelegatesByNID.GetOrDefault(NID, null); } return((CpuThreadState) => { if (Callback == null) { if (CpuThreadState.CpuProcessor.PspConfig.DebugSyscalls) { Console.WriteLine( "Thread({0}:'{1}'):{2}:{3}", PspEmulatorContext.GetInstance <HleThreadManager>().Current.Id, PspEmulatorContext.GetInstance <HleThreadManager>().Current.Name, ModuleImportName, NIDName ); } throw (new NotImplementedException("Not Implemented '" + String.Format("{0}:{1}", ModuleImportName, NIDName) + "'")); } else { Callback(CpuThreadState); } }); }
public void ElfLoaderConstructorTest() { var PspConfig = new PspConfig(); var PspEmulatorContext = new PspEmulatorContext(PspConfig); PspEmulatorContext.SetInstanceType<PspMemory, LazyPspMemory>(); var Memory = PspEmulatorContext.GetInstance<PspMemory>(); var MemoryStream = new PspMemoryStream(Memory); var MemoryPartition = new MemoryPartition(PspMemory.MainOffset, PspMemory.MainOffset + PspMemory.MainSize); var ElfLoader = new ElfLoader(); ElfLoader.Load(File.OpenRead("../../../TestInput/minifire.elf")); ElfLoader.AllocateAndWrite(MemoryStream, MemoryPartition); Assert.AreEqual(1, ElfLoader.ProgramHeaders.Length); Assert.AreEqual(3, ElfLoader.SectionHeaders.Length); Assert.AreEqual( "['','.rodata.sceModuleInfo']".Replace('\'', '"'), ElfLoader.SectionHeadersByName.Keys.ToJson() ); //ElfLoader.LoadAllocateMemory(MemoryPartition); //ElfLoader.LoadWriteToMemory(MemoryStream); //var ModuleInfo = ElfLoader.ModuleInfo; var PC = ElfLoader.Header.EntryPoint; //var GP = ModuleInfo.GP; Assert.AreEqual(0x08900008, (int)PC); //Assert.AreEqual(0x00004821, (int)GP); }
public override void InitializeComponent() { this.Callbacks = new HleUidPool <HleCallback>(); this.ScheduledCallbacks = new Queue <HleCallback>(); this.CpuProcessor = PspEmulatorContext.GetInstance <CpuProcessor>(); this.HleInterop = PspEmulatorContext.GetInstance <HleInterop>(); }
/// <summary> /// /// </summary> public override void InitializeComponent() { this.Config = PspEmulatorContext.PspConfig; this.Memory = PspEmulatorContext.GetInstance <PspMemory>(); this.TextureCache = PspEmulatorContext.GetInstance <TextureCache>(); this.VertexReader = new VertexReader(); }
public void _InitializeComponent(PspEmulatorContext PspEmulatorContext) { //Console.WriteLine("_InitializeComponent : {0}", this.GetType()); if (this.PspEmulatorContext != null) throw(new Exception("Can't call _InitializeComponent twice.")); this.PspEmulatorContext = PspEmulatorContext; PspEmulatorContext.InjectDependencesTo(this); }
public void ElfLoaderConstructorTest() { var PspConfig = new PspConfig(); var PspEmulatorContext = new PspEmulatorContext(PspConfig); PspEmulatorContext.SetInstanceType <PspMemory, LazyPspMemory>(); var Memory = PspEmulatorContext.GetInstance <PspMemory>(); var MemoryStream = new PspMemoryStream(Memory); var MemoryPartition = new MemoryPartition(PspMemory.MainOffset, PspMemory.MainOffset + PspMemory.MainSize); var ElfLoader = new ElfLoader(); ElfLoader.Load(File.OpenRead("../../../TestInput/minifire.elf")); ElfLoader.AllocateAndWrite(MemoryStream, MemoryPartition); Assert.AreEqual(1, ElfLoader.ProgramHeaders.Length); Assert.AreEqual(3, ElfLoader.SectionHeaders.Length); Assert.AreEqual( "['','.rodata.sceModuleInfo']".Replace('\'', '"'), ElfLoader.SectionHeadersByName.Keys.ToJson() ); //ElfLoader.LoadAllocateMemory(MemoryPartition); //ElfLoader.LoadWriteToMemory(MemoryStream); //var ModuleInfo = ElfLoader.ModuleInfo; var PC = ElfLoader.Header.EntryPoint; //var GP = ModuleInfo.GP; Assert.AreEqual(0x08900008, (int)PC); //Assert.AreEqual(0x00004821, (int)GP); }
public override void InitializeComponent() { this.IsRunning = true; this.CpuProcessor = PspEmulatorContext.GetInstance <CpuProcessor>(); this.GpuProcessor = PspEmulatorContext.GetInstance <GpuProcessor>(); this.PspAudio = PspEmulatorContext.GetInstance <PspAudio>(); this.PspConfig = PspEmulatorContext.PspConfig; this.PspRtc = PspEmulatorContext.GetInstance <PspRtc>(); this.PspDisplay = PspEmulatorContext.GetInstance <PspDisplay>(); this.PspController = PspEmulatorContext.GetInstance <PspController>(); this.MipsEmiter = new MipsEmiter(); this.Kirk = new Kirk(); this.Kirk.kirk_init(); this.HleOutputHandler = PspEmulatorContext.GetInstance <HleOutputHandler>(); // @TODO FIX! New Instances!? this.ThreadManager = PspEmulatorContext.GetInstance <HleThreadManager>(); this.SemaphoreManager = PspEmulatorContext.GetInstance <HleSemaphoreManager>(); this.EventFlagManager = PspEmulatorContext.GetInstance <HleEventFlagManager>(); this.MemoryManager = new HleMemoryManager(this.CpuProcessor.Memory); this.ModuleManager = PspEmulatorContext.GetInstance <HleModuleManager>(); this.CallbackManager = PspEmulatorContext.GetInstance <HleCallbackManager>(); this.HleIoManager = PspEmulatorContext.GetInstance <HleIoManager>(); this.HleRegistryManager = PspEmulatorContext.GetInstance <HleRegistryManager>(); this.HleInterruptManager = PspEmulatorContext.GetInstance <HleInterruptManager>(); }
public static void ClassInit(TestContext context) { PspConfig = new PspConfig(); PspEmulatorContext = new PspEmulatorContext(PspConfig); PspEmulatorContext.SetInstanceType <PspMemory, LazyPspMemory>(); Memory = PspEmulatorContext.GetInstance <PspMemory>(); }
public LlePspCpu(string Name, PspEmulatorContext PspEmulatorContext, CpuProcessor CpuProcessor, uint EntryPoint = 0x1fc00000) { this.Name = Name; //this.CachedGetMethodCache = PspEmulatorContext.GetInstance<CachedGetMethodCache>(); this.CpuThreadState = new CpuThreadState(CpuProcessor); this.EntryPoint = EntryPoint; }
public void TestMethod1() { var Config = new PspConfig(); var PspEmulatorContext = new PspEmulatorContext(Config); PspEmulatorContext.SetInstanceType<PspMemory, LazyPspMemory>(); var PspMemory = PspEmulatorContext.GetInstance<PspMemory>(); var PspMemoryStream = new PspMemoryStream(PspMemory); var MipsAssembler = new MipsAssembler(PspMemoryStream); var DynarecFunctionCompilerTask = PspEmulatorContext.GetInstance<DynarecFunctionCompilerTask>(); var CpuProcessor = PspEmulatorContext.GetInstance<CpuProcessor>(); var CpuThreadState = new CpuThreadState(CpuProcessor); MipsAssembler.Assemble(@" .code 0x08000000 addi r1, r1, 1 jr r31 nop "); var DynarecFunction = DynarecFunctionCompilerTask.GetFunctionForAddress(PspMemory.MainSegment.Low); Assert.AreEqual(0, CpuThreadState.GPR[1]); DynarecFunction.Delegate(CpuThreadState); Assert.AreEqual(1, CpuThreadState.GPR[1]); }
public static void ClassInit(TestContext context) { PspConfig = new PspConfig(); PspEmulatorContext = new PspEmulatorContext(PspConfig); PspEmulatorContext.SetInstanceType<PspMemory, LazyPspMemory>(); Memory = PspEmulatorContext.GetInstance<PspMemory>(); }
public void SetUp() { PspConfig = new PspConfig(); PspEmulatorContext = new PspEmulatorContext(PspConfig); PspEmulatorContext.SetInstanceType <PspMemory, LazyPspMemory>(); Processor = PspEmulatorContext.GetInstance <CpuProcessor>(); MipsAssembler = new MipsAssembler(new PspMemoryStream(PspEmulatorContext.GetInstance <PspMemory>())); }
public void SetUp() { PspConfig = new PspConfig(); PspEmulatorContext = new PspEmulatorContext(PspConfig); PspEmulatorContext.SetInstanceType<PspMemory, LazyPspMemory>(); Processor = PspEmulatorContext.GetInstance<CpuProcessor>(); MipsAssembler = new MipsAssembler(new PspMemoryStream(PspEmulatorContext.GetInstance<PspMemory>())); }
public HleModuleHost GetModuleByType(Type Type) { if (!HleModules.ContainsKey(Type)) { var HleModule = HleModules[Type] = (HleModuleHost)Activator.CreateInstance(Type); HleModule.Initialize(PspEmulatorContext.GetInstance <HleState>()); } return((HleModuleHost)HleModules[Type]); }
public override void InitializeComponent() { CpuProcessor = PspEmulatorContext.GetInstance <CpuProcessor>(); PspRtc = PspEmulatorContext.GetInstance <PspRtc>(); ThreadManager = PspEmulatorContext.GetInstance <HleThreadManager>(); HleState = PspEmulatorContext.GetInstance <HleState>(); PspMemory = PspEmulatorContext.GetInstance <PspMemory>(); RegisterDevices(); }
public void SetUp() { var PspEmulatorContext = new PspEmulatorContext(new PspConfig()); PspEmulatorContext.SetInstanceType<PspMemory, LazyPspMemory>(); SetMocks(PspEmulatorContext); PspEmulatorContext.InjectDependencesTo(this); Initialize(); }
public void Initialize(PspEmulatorContext PspEmulatorContext) { //this.PspEmulatorContext = PspEmulatorContext; PspEmulatorContext.InjectDependencesTo(this); this.ModuleLocation = "flash0:/kd/" + this.GetType().Namespace.Split('.').Last() + ".prx"; //Console.WriteLine(this.ModuleLocation); //Console.ReadKey(); //try { foreach ( var MethodInfo in new MethodInfo[0] .Concat(this.GetType().GetMethods()) //.Concat(this.GetType().GetMethods(BindingFlags.NonPublic)) //.Concat(this.GetType().GetMethods(BindingFlags.Public)) ) { var Attributes = MethodInfo.GetCustomAttributes(typeof(HlePspFunctionAttribute), true).Cast<HlePspFunctionAttribute>(); if (Attributes.Count() > 0) { if (!MethodInfo.IsPublic) { throw(new InvalidProgramException("Method " + MethodInfo + " is not public")); } var Delegate = CreateDelegateForMethodInfo(MethodInfo, Attributes.First()); DelegatesByName[MethodInfo.Name] = Delegate; foreach (var Attribute in Attributes) { //Console.WriteLine("HleModuleHost: {0}, {1}", "0x%08X".Sprintf(Attribute.NID), MethodInfo.Name); DelegatesByNID[Attribute.NID] = Delegate; EntriesByNID[Attribute.NID] = new FunctionEntry() { NID = Attribute.NID, Name = MethodInfo.Name, Description = "", Module = this, ModuleName = this.Name, }; } } else { //Console.WriteLine("HleModuleHost: NO: {0}", MethodInfo.Name); } } } //catch (Exception Exception) //{ // Console.WriteLine(Exception); // throw (Exception); //} }
static protected string RunExecutableAndGetOutput(string PspAutoTestsFolder, string FileName) { var OutputString = ""; GC.Collect(); var PspEmulatorContext = new PspEmulatorContext(PspConfig); ConsoleUtils.CaptureOutput(() => { PspEmulatorContext.SetInstanceType <PspMemory, NormalPspMemory>(); PspEmulatorContext.SetInstanceType <GpuImpl, GpuImplMock>(); PspEmulatorContext.SetInstanceType <PspAudioImpl, AudioImplMock>(); PspEmulatorContext.SetInstanceType <HleOutputHandler, HleOutputHandlerMock>(); var Start = DateTime.Now; PspEmulatorContext.GetInstance <HleModuleManager>(); var End = DateTime.Now; Console.WriteLine(End - Start); var GpuImpl = PspEmulatorContext.GetInstance <GpuImpl>(); GpuImpl.InitSynchronizedOnce(); var PspRunner = PspEmulatorContext.GetInstance <PspRunner>(); PspRunner.StartSynchronized(); { try { //PspRunner.CpuComponentThread.SetIso(PspAutoTestsFolder + "/../input/test.cso"); PspRunner.CpuComponentThread.SetIso(PspAutoTestsFolder + "/../input/cube.cso"); PspRunner.CpuComponentThread._LoadFile(FileName); if (!PspRunner.CpuComponentThread.StoppedEndedEvent.WaitOne(TimeSpan.FromSeconds(5))) { Console.Error.WriteLine("Timeout!"); } } catch (Exception Exception) { Console.Error.WriteLine(Exception); } } PspRunner.StopSynchronized(); }, //Capture: false Capture: true ); var HleOutputHandlerMock = (HleOutputHandlerMock)PspEmulatorContext.GetInstance <HleOutputHandler>(); OutputString = HleOutputHandlerMock.OutputString; return(OutputString); }
public override void InitializeComponent() { if (sizeof(uint *) != 4) { throw(new NotImplementedException("At the moment the only supported target is 32-bits")); } RunnableComponentList.Add(CpuComponentThread = PspEmulatorContext.GetInstance <CpuComponentThread>()); RunnableComponentList.Add(GpuComponentThread = PspEmulatorContext.GetInstance <GpuComponentThread>()); RunnableComponentList.Add(AudioComponentThread = PspEmulatorContext.GetInstance <AudioComponentThread>()); RunnableComponentList.Add(DisplayComponentThread = PspEmulatorContext.GetInstance <DisplayComponentThread>()); }
public VirtualTimer(PspEmulatorContext PspEmulatorContext, string Name) { PspEmulatorContext.InjectDependencesTo(this); this.Timer = PspRtc.CreateVirtualTimer(Handler); this.Name = Name; this.Timer.Enabled = false; this.PspSharedInfoMemoryPartition = MemoryManager.GetPartition(HleMemoryManager.Partitions.Kernel0).Allocate( sizeof(PspSharedInfoStruct), Name: "VTimer.PspSharedInfoStruct" ); this.PspSharedInfo = (PspSharedInfoStruct*)CpuProcessor.Memory.PspAddressToPointerSafe(this.PspSharedInfoMemoryPartition.Low); }
public void ParsePathTest() { var PspEmulatorContext = new PspEmulatorContext(new PspConfig()); var HleIoManager = PspEmulatorContext.GetInstance<HleIoManager>(); var DriverName = "ms:"; var Driver = new HleIoDriverLocalFileSystem("C:/$INVALID$PATH$"); HleIoManager.SetDriver(DriverName, Driver); var Parts = HleIoManager.ParsePath("ms3:/path/to/file.txt"); Assert.AreEqual(Driver, Parts.HleIoDrvFileArg.HleIoDriver); Assert.AreEqual(3, Parts.HleIoDrvFileArg.FileSystemNumber); Assert.AreEqual("/path/to/file.txt", Parts.LocalPath); }
public void SetUp() { PspConfig = new PspConfig(); PspConfig.HleModulesDll = Assembly.GetExecutingAssembly(); PspEmulatorContext = new PspEmulatorContext(PspConfig); PspEmulatorContext.SetInstanceType<PspMemory, LazyPspMemory>(); PspEmulatorContext.SetInstanceType<GpuImpl, GpuImplNull>(); PspEmulatorContext.SetInstanceType<PspAudioImpl, AudioImplNull>(); Memory = PspEmulatorContext.GetInstance<PspMemory>(); ThreadManager = PspEmulatorContext.GetInstance<HleThreadManager>(); Processor = PspEmulatorContext.GetInstance<CpuProcessor>(); MipsAssembler = new MipsAssembler(new PspMemoryStream(Memory)); }
public void ParsePathTest() { var PspEmulatorContext = new PspEmulatorContext(new PspConfig()); var HleIoManager = PspEmulatorContext.GetInstance <HleIoManager>(); var DriverName = "ms:"; var Driver = new HleIoDriverLocalFileSystem("C:/$INVALID$PATH$"); HleIoManager.SetDriver(DriverName, Driver); var Parts = HleIoManager.ParsePath("ms3:/path/to/file.txt"); Assert.AreEqual(Driver, Parts.HleIoDrvFileArg.HleIoDriver); Assert.AreEqual(3, Parts.HleIoDrvFileArg.FileSystemNumber); Assert.AreEqual("/path/to/file.txt", Parts.LocalPath); }
public override void InitializeComponent() { HleModuleTypes = GetAllHleModules(PspEmulatorContext.PspConfig.HleModulesDll).ToDictionary(Type => Type.Name); Console.WriteLine("HleModuleTypes: {0}", HleModuleTypes.Count); PspEmulatorContext.GetInstance <CpuProcessor>().RegisterNativeSyscall(FunctionGenerator.NativeCallSyscallCode, (Code, CpuThreadState) => { uint Info = CpuThreadState.CpuProcessor.Memory.Read4(CpuThreadState.PC + 4); { //Console.WriteLine("{0:X}", CpuThreadState.RA); DelegateTable[Info](CpuThreadState); } CpuThreadState.PC = CpuThreadState.RA; }); }
public override void InitializeComponent() { this.HleCallbackManager = PspEmulatorContext.GetInstance <HleCallbackManager>(); this.CpuProcessor = PspEmulatorContext.GetInstance <CpuProcessor>(); this.HleInterop = PspEmulatorContext.GetInstance <HleInterop>(); //uint MaxHandlers = Enum.GetValues(typeof(PspInterrupts)).OfType<uint>().Max() + 1; InterruptHandlers = new HleInterruptHandler[(int)PspInterrupts._MAX]; for (int n = 0; n < InterruptHandlers.Length; n++) { InterruptHandlers[n] = new HleInterruptHandler( this, (PspInterrupts)n, HleCallbackManager ); } }
protected override void Main() { PspEmulatorContext.GetInstance <GpuImpl>().InitSynchronizedOnce(); GpuProcessor.ProcessInit(); while (true) { ThreadTaskQueue.HandleEnqueued(); if (!Running) { return; } GpuProcessor.ProcessStep(); } }
public void CreateDelegateTest() { var PspConfig = new PspConfig(); var PspEmulatorContext = new PspEmulatorContext(PspConfig); PspEmulatorContext.SetInstanceType<PspMemory, LazyPspMemory>(); var Memory = PspEmulatorContext.GetInstance<PspMemory>(); var Processor = PspEmulatorContext.GetInstance<CpuProcessor>(); var CpuThreadState = new CpuThreadState(Processor); var MipsEmiter = new MipsMethodEmiter(new MipsEmiter(), Processor, 0); CpuThreadState.GPR[1] = 1; CpuThreadState.GPR[2] = 2; CpuThreadState.GPR[3] = 3; MipsEmiter.OP_3REG_Unsigned(1, 2, 2, () => { MipsEmiter.SafeILGenerator.BinaryOperation(SafeBinaryOperator.AdditionSigned); }); MipsEmiter.OP_3REG_Unsigned(0, 2, 2, () => { MipsEmiter.SafeILGenerator.BinaryOperation(SafeBinaryOperator.AdditionSigned); }); MipsEmiter.OP_2REG_IMM_Signed(10, 0, 1000, () => { MipsEmiter.SafeILGenerator.BinaryOperation(SafeBinaryOperator.AdditionSigned); }); MipsEmiter.CreateDelegate()(CpuThreadState); Assert.AreEqual(4, CpuThreadState.GPR[1]); Assert.AreEqual(0, CpuThreadState.GPR[0]); Assert.AreEqual(1000, CpuThreadState.GPR[10]); }
/// <summary> /// /// </summary> /// <param name="PspConfig"></param> /// <param name="Memory"></param> public override void InitializeComponent() { if (sizeof(GpuStateStruct) > sizeof(uint) * 512) { throw (new InvalidProgramException("GpuStateStruct too big. Maybe x64? . Size: " + sizeof(GpuStateStruct))); } this.PspConfig = PspEmulatorContext.PspConfig; this.Memory = PspEmulatorContext.GetInstance <PspMemory>(); this.GpuImpl = PspEmulatorContext.GetInstance <GpuImpl>(); this.DisplayListQueue = new LinkedList <GpuDisplayList>(); this.DisplayListFreeQueue = new Queue <GpuDisplayList>(); for (int n = 0; n < DisplayLists.Length; n++) { var DisplayList = new GpuDisplayList(Memory, this, n); this.DisplayLists[n] = DisplayList; //this.DisplayListFreeQueue.Enqueue(DisplayLists[n]); EnqueueFreeDisplayList(DisplayLists[n]); } }
public void CreateDelegateTest() { var PspConfig = new PspConfig(); var PspEmulatorContext = new PspEmulatorContext(PspConfig); PspEmulatorContext.SetInstanceType <PspMemory, LazyPspMemory>(); var Memory = PspEmulatorContext.GetInstance <PspMemory>(); var Processor = PspEmulatorContext.GetInstance <CpuProcessor>(); var CpuThreadState = new CpuThreadState(Processor); var MipsEmiter = new MipsMethodEmiter(new MipsEmiter(), Processor); CpuThreadState.GPR[1] = 1; CpuThreadState.GPR[2] = 2; CpuThreadState.GPR[3] = 3; MipsEmiter.OP_3REG_Unsigned(1, 2, 2, OpCodes.Add); MipsEmiter.OP_3REG_Unsigned(0, 2, 2, OpCodes.Add); MipsEmiter.OP_2REG_IMM_Signed(10, 0, 1000, OpCodes.Add); MipsEmiter.CreateDelegate()(CpuThreadState); Assert.AreEqual(4, CpuThreadState.GPR[1]); Assert.AreEqual(0, CpuThreadState.GPR[0]); Assert.AreEqual(1000, CpuThreadState.GPR[10]); }
public void TestMethod1() { var Config = new PspConfig(); var PspEmulatorContext = new PspEmulatorContext(Config); PspEmulatorContext.SetInstanceType<PspMemory, LazyPspMemory>(); var DynarecFunctionCompiler = PspEmulatorContext.GetInstance<DynarecFunctionCompiler>(); var CpuProcessor = PspEmulatorContext.GetInstance<CpuProcessor>(); var CpuThreadState = new CpuThreadState(CpuProcessor); var DynarecFunction = DynarecFunctionCompiler.CreateFunction( new InstructionArrayReader(MipsAssembler.StaticAssembleInstructions(@" addi r1, r1, 1 jr r31 nop ")), 0 ); Assert.AreEqual(0, CpuThreadState.GPR[1]); DynarecFunction.Delegate(CpuThreadState); Assert.AreEqual(1, CpuThreadState.GPR[1]); }
protected static string RunExecutableAndGetOutput(string PspAutoTestsFolder, string FileName, out string CapturedOutput, string FileNameBase) { var OutputString = ""; IHleIoDriver HostDriver = null; using (var PspEmulatorContext = new PspEmulatorContext(PspConfig)) { CapturedOutput = ConsoleUtils.CaptureOutput(() => { //Console.Error.WriteLine("[0]"); //PspEmulatorContext.SetInstanceType<PspMemory, NormalPspMemory>(); PspEmulatorContext.SetInstanceType<PspMemory, FastPspMemory>(); //PspEmulatorContext.SetInstanceType<GpuImpl, GpuImplMock>(); PspEmulatorContext.SetInstanceType<GpuImpl, OpenglGpuImpl>(); PspEmulatorContext.SetInstanceType<PspAudioImpl, AudioImplNull>(); PspEmulatorContext.SetInstanceType<HleOutputHandler, HleOutputHandlerMock>(); //Console.Error.WriteLine("[1]"); PspConfig.FileNameBase = FileNameBase; var Start = DateTime.UtcNow; PspEmulatorContext.GetInstance<HleModuleManager>(); var End = DateTime.UtcNow; Console.WriteLine(End - Start); //Console.Error.WriteLine("[a]"); // GPU -> NULL //PspEmulatorContext.SetInstanceType<GpuImpl>(typeof(GpuImplOpenglEs)); PspEmulatorContext.SetInstanceType<GpuImpl>(typeof(GpuImplNull)); var GpuImpl = PspEmulatorContext.GetInstance<GpuImpl>(); //GpuImpl.InitSynchronizedOnce(); //Console.Error.WriteLine("[b]"); var PspRunner = PspEmulatorContext.GetInstance<PspRunner>(); PspRunner.StartSynchronized(); //Console.Error.WriteLine("[c]"); { try { //PspRunner.CpuComponentThread.SetIso(PspAutoTestsFolder + "/../input/test.cso"); PspRunner.CpuComponentThread.SetIso(PspAutoTestsFolder + "/../input/cube.cso"); //Console.Error.WriteLine("[2]"); var HleIoManager = PspEmulatorContext.GetInstance<HleIoManager>(); HostDriver = HleIoManager.GetDriver("host:"); try { HostDriver.IoRemove(null, "/__testoutput.txt"); } catch { } try { HostDriver.IoRemove(null, "/__testerror.txt"); } catch { } PspRunner.CpuComponentThread._LoadFile(FileName); //Console.Error.WriteLine("[3]"); if (!PspRunner.CpuComponentThread.StoppedEndedEvent.WaitOne(TimeSpan.FromSeconds(10))) { Console.Error.WriteLine("Timeout!"); } } catch (Exception Exception) { Console.Error.WriteLine(Exception); } } PspRunner.StopSynchronized(); GC.Collect(); using (var test_output = HostDriver.OpenRead("/__testoutput.txt")) { OutputString = test_output.ReadAllContentsAsString(); } }, //Capture: false Capture: true ); //var HleOutputHandlerMock = (HleOutputHandlerMock)PspEmulatorContext.GetInstance<HleOutputHandler>(); //OutputString = HleOutputHandlerMock.OutputString; } return OutputString; }
protected override void SetMocks(PspEmulatorContext PspEmulatorContext) { PspEmulatorContext.SetInstanceType<PspRtc, PspRtcMock>(); }
public override void InitializeComponent() { this.HleInterruptManager = PspEmulatorContext.GetInstance <HleInterruptManager>(); }
public override void InitializeComponent() { GpuProcessor = PspEmulatorContext.GetInstance <GpuProcessor>(); }
/// <summary> /// /// </summary> public override void InitializeComponent() { this.PspAudioImpl = PspEmulatorContext.GetInstance <PspAudioImpl>(); Initialize(); }
void CreateNewContextAndRemoveOldOne() { ContextInitializedFlag = false; ContextInitialized.Reset(); { // Stops the current context if it has one already. if (PspRunner != null) { PspRunner.StopSynchronized(); PspEmulatorContext.GetInstance<PspMemory>().Dispose(); PspEmulatorContext.GetInstance<GpuImpl>().StopSynchronized(); PspEmulatorContext.GetInstance<PspAudioImpl>().StopSynchronized(); PspRunner = null; PspEmulatorContext = null; GC.Collect(); } PspConfig.HleModulesDll = typeof(HleModulesRoot).Assembly; /* foreach (var FileName in new [] { Path.GetDirectoryName(typeof(Program).Assembly.Location) + @"\CSPspEmu.Hle.Modules.dll", Application.ExecutablePath, }) { if (File.Exists(FileName)) { PspConfig.HleModulesDll = Assembly.LoadFile(FileName); break; } } */ // PspEmulatorContext = new PspEmulatorContext(PspConfig); { // GPU PspPluginImpl.SelectWorkingPlugin<GpuImpl>(PspEmulatorContext, typeof(OpenglGpuImpl), typeof(GpuImplSoft), typeof(GpuImplNull) ); // AUDIO PspPluginImpl.SelectWorkingPlugin<PspAudioImpl>(PspEmulatorContext, typeof(PspAudioOpenalImpl), typeof(PspAudioWaveOutImpl), typeof(AudioAlsaImpl), typeof(AudioImplNull) ); // Memory if (PspConfig.StoredConfig.UseFastMemory) { PspEmulatorContext.SetInstanceType<PspMemory, FastPspMemory>(); } else { PspEmulatorContext.SetInstanceType<PspMemory, NormalPspMemory>(); } } PspEmulatorContext.GetInstance<PspDisplay>().VBlankEventCall += new Action(PspEmulator_VBlankEventCall); PspRunner = PspEmulatorContext.GetInstance<PspRunner>(); PspRunner.StartSynchronized(); var GpuImpl = PspEmulatorContext.GetInstance<GpuImpl>(); GpuImpl.InitSynchronizedOnce(); } ContextInitializedFlag = true; ContextInitialized.Set(); }
public HleModuleGuest(PspEmulatorContext PspEmulatorContext) { PspEmulatorContext.InjectDependencesTo(this); }
public Atrac(PspEmulatorContext PspEmulatorContext, byte[] Data) { CodecType = CodecType.PSP_MODE_AT_3_PLUS; SetData(Data); }
public void _LoadFile(String FileName) { //GC.Collect(); SetVirtualFolder(Path.GetDirectoryName(FileName)); var MemoryStream = new PspMemoryStream(PspMemory); var Loader = PspEmulatorContext.GetInstance <ElfPspLoader>(); Stream LoadStream = File.OpenRead(FileName); //using () { Stream ElfLoadStream = null; var Format = new FormatDetector().Detect(LoadStream); switch (Format) { case "Pbp": ElfLoadStream = new Pbp().Load(LoadStream)["psp.data"]; break; case "Elf": ElfLoadStream = LoadStream; break; case "Cso": case "Iso": { var Iso = SetIso(FileName); ElfLoadStream = Iso.Root.Locate("/PSP_GAME/SYSDIR/BOOT.BIN").Open(); } break; default: throw (new NotImplementedException("Can't load format '" + Format + "'")); } Loader.Load( ElfLoadStream, MemoryStream, HleState.MemoryManager.GetPartition(HleMemoryManager.Partitions.User), HleState.ModuleManager ); RegisterSyscalls(); uint CODE_PTR_ARGUMENTS = 0x08000100; { var BinaryWriter = new BinaryWriter(MemoryStream); var StreamWriter = new StreamWriter(MemoryStream); StreamWriter.AutoFlush = true; MemoryStream.Position = CODE_PTR_ARGUMENTS; BinaryWriter.Write((uint)(CODE_PTR_ARGUMENTS + 4)); BinaryWriter.Flush(); StreamWriter.Write("ms0:/PSP/GAME/virtual/EBOOT.PBP\0"); StreamWriter.Flush(); } uint argc = 1; uint argv = CODE_PTR_ARGUMENTS + 4; //uint argv = CODE_PTR_ARGUMENTS; var MainThread = HleState.ThreadManager.Create(); var CpuThreadState = MainThread.CpuThreadState; { CpuThreadState.PC = Loader.InitInfo.PC; CpuThreadState.GP = Loader.InitInfo.GP; CpuThreadState.SP = HleState.MemoryManager.GetPartition(HleMemoryManager.Partitions.User).Allocate(0x1000, MemoryPartition.Anchor.High, Alignment: 0x100).High; CpuThreadState.K0 = MainThread.CpuThreadState.SP; CpuThreadState.RA = HleEmulatorSpecialAddresses.CODE_PTR_EXIT_THREAD; CpuThreadState.GPR[4] = (int)argc; // A0 CpuThreadState.GPR[5] = (int)argv; // A1 } CpuThreadState.DumpRegisters(); HleState.MemoryManager.GetPartition(HleMemoryManager.Partitions.User).Dump(); MainThread.CurrentStatus = HleThread.Status.Ready; } }
public override void InitializeComponent() { this.Processor = PspEmulatorContext.GetInstance <CpuProcessor>(); this.HleCallbackManager = PspEmulatorContext.GetInstance <HleCallbackManager>(); this.HleInterruptManager = PspEmulatorContext.GetInstance <HleInterruptManager>(); }
protected override void SetMocks(PspEmulatorContext PspEmulatorContext) { PspEmulatorContext.SetInstanceType<PspRtc, PspRtcMock>(); (PspEmulatorContext.GetInstance<PspRtc>() as PspRtcMock).sceRtcTest = this; }
public GuestHleIoDriver(PspEmulatorContext PspEmulatorContext, PspIoDrv* PspIoDrv) { PspEmulatorContext.InjectDependencesTo(this); this.PspIoDrv = PspIoDrv; }
void CreateNewContextAndRemoveOldOne() { ContextInitializedFlag = false; ContextInitialized.Reset(); { // Stops the current context if it has one already. if (PspRunner != null) { PspRunner.StopSynchronized(); PspEmulatorContext.GetInstance <PspMemory>().Dispose(); PspEmulatorContext.GetInstance <GpuImpl>().StopSynchronized(); PspEmulatorContext.GetInstance <PspAudioImpl>().StopSynchronized(); PspRunner = null; PspEmulatorContext = null; GC.Collect(); } foreach (var FileName in new [] { Path.GetDirectoryName(typeof(Program).Assembly.Location) + @"\CSPspEmu.Hle.Modules.dll", Application.ExecutablePath, }) { if (File.Exists(FileName)) { PspConfig.HleModulesDll = Assembly.LoadFile(FileName); break; } } // PspEmulatorContext = new PspEmulatorContext(PspConfig); { PspEmulatorContext.SetInstanceType <GpuImpl, OpenglGpuImpl>(); PspEmulatorContext.SetInstanceType <PspAudioImpl, PspAudioOpenalImpl>(); #if RELEASE PspEmulatorContext.SetInstanceType <PspMemory, FastPspMemory>(); #else PspEmulatorContext.SetInstanceType <PspMemory, NormalPspMemory>(); #endif /* * if (PspConfig.UseFastAndUnsaferMemory) * { * PspEmulatorContext.SetInstanceType<PspMemory, FastPspMemory>(); * } * else * { * PspEmulatorContext.SetInstanceType<PspMemory, NormalPspMemory>(); * } */ } PspRunner = PspEmulatorContext.GetInstance <PspRunner>(); PspRunner.StartSynchronized(); var GpuImpl = PspEmulatorContext.GetInstance <GpuImpl>(); GpuImpl.InitSynchronizedOnce(); } ContextInitializedFlag = true; ContextInitialized.Set(); }
public override void InitializeComponent() { this.PspConfig = PspEmulatorContext.PspConfig; this.Memory = PspEmulatorContext.GetInstance <PspMemory>(); Reset(); }
protected static string RunExecutableAndGetOutput(string PspAutoTestsFolder, string FileName) { var OutputString = ""; GC.Collect(); var PspEmulatorContext = new PspEmulatorContext(PspConfig); ConsoleUtils.CaptureOutput(() => { PspEmulatorContext.SetInstanceType<PspMemory, NormalPspMemory>(); PspEmulatorContext.SetInstanceType<GpuImpl, GpuImplMock>(); PspEmulatorContext.SetInstanceType<PspAudioImpl, AudioImplMock>(); PspEmulatorContext.SetInstanceType<HleOutputHandler, HleOutputHandlerMock>(); var Start = DateTime.Now; PspEmulatorContext.GetInstance<HleModuleManager>(); var End = DateTime.Now; Console.WriteLine(End - Start); var GpuImpl = PspEmulatorContext.GetInstance<GpuImpl>(); GpuImpl.InitSynchronizedOnce(); var PspRunner = PspEmulatorContext.GetInstance<PspRunner>(); PspRunner.StartSynchronized(); { try { //PspRunner.CpuComponentThread.SetIso(PspAutoTestsFolder + "/../input/test.cso"); PspRunner.CpuComponentThread.SetIso(PspAutoTestsFolder + "/../input/cube.cso"); PspRunner.CpuComponentThread._LoadFile(FileName); if (!PspRunner.CpuComponentThread.StoppedEndedEvent.WaitOne(TimeSpan.FromSeconds(5))) { Console.Error.WriteLine("Timeout!"); } } catch (Exception Exception) { Console.Error.WriteLine(Exception); } } PspRunner.StopSynchronized(); }, //Capture: false Capture: true ); var HleOutputHandlerMock = (HleOutputHandlerMock)PspEmulatorContext.GetInstance<HleOutputHandler>(); OutputString = HleOutputHandlerMock.OutputString; return OutputString; }
protected virtual void SetMocks(PspEmulatorContext PspEmulatorContext) { }
public override void InitializeComponent() { PspMemory = PspEmulatorContext.GetInstance <PspMemory>(); }
static void Main(string[] args) { var PspConfig = new PspConfig(); var PspEmulatorContext = new PspEmulatorContext(PspConfig); var DebugPspMemory = PspEmulatorContext.GetInstance<DebugPspMemory>(); PspEmulatorContext.SetInstance<PspMemory>(DebugPspMemory); var CpuProcessor = PspEmulatorContext.GetInstance<CpuProcessor>(); var CpuThreadState = new CpuThreadState(CpuProcessor); var Dma = new Dma(CpuThreadState); DebugPspMemory.CpuThreadState = CpuThreadState; DebugPspMemory.Dma = Dma; Console.SetWindowSize(120, 60); Console.SetBufferSize(120, 8000); PspConfig.MustLogWrites = true; var NandStream = File.OpenRead(NandPath); //DebugPspMemory.Write4(0xBFC00FFC, 0x20040420); // It doesn't start the ME //DebugPspMemory.Write4(0xBFC00FFC, 0xFFFFFFFF); #if false // PRE-IPL uint StartPC = 0x1FC00000; DebugPspMemory.WriteBytes(StartPC, File.ReadAllBytes(PreIplPath)); PspConfig.TraceJal = true; //PspConfig.TraceJIT = true; #else var IplReader = new IplReader(new NandReader(NandStream)); var Info = IplReader.LoadIplToMemory(new PspMemoryStream(DebugPspMemory)); uint StartPC = Info.EntryFunction; #endif /* ME: li $t0, 0x40EC19C jr $t0 nop */ //IplReader.WriteIplToFile(File.Open(NandPath + ".ipl.bin", FileMode.Create, FileAccess.Write)); var LLEState = new LLEState(); Dma.LLEState = LLEState; LLEState.GPIO = new LleGPIO(); LLEState.NAND = new LleNAND(NandStream); LLEState.Cpu = new LlePspCpu("CPU", PspEmulatorContext, CpuProcessor, StartPC); LLEState.Me = new LlePspCpu("ME", PspEmulatorContext, CpuProcessor, StartPC); LLEState.LleKirk = new LleKirk(DebugPspMemory); LLEState.Memory = DebugPspMemory; LLEState.Cpu.Start(); while (true) Thread.Sleep(int.MaxValue); }
public HleIoDriverMemoryStick(PspEmulatorContext PspEmulatorContext, IHleIoDriver HleIoDriver) : base(HleIoDriver) { PspEmulatorContext.InjectDependencesTo(this); }
public Atrac(PspEmulatorContext PspEmulatorContext, CodecType CodecType) { this.CodecType = CodecType; }
public Atrac(PspEmulatorContext PspEmulatorContext, CodecType CodecType) { PspEmulatorContext.InjectDependencesTo(this); PrimaryBuffer = HleMemoryManager.GetPartition(Managers.HleMemoryManager.Partitions.User).Allocate(1024); this.CodecType = CodecType; }
public HleThread(PspEmulatorContext PspEmulatorContext, CpuThreadState CpuThreadState) { this.HleInterruptManager = PspEmulatorContext.GetInstance<HleInterruptManager>(); this.HleThreadManager = PspEmulatorContext.GetInstance<HleThreadManager>(); this.MethodCache = CpuThreadState.CpuProcessor.MethodCache; this.PspConfig = CpuThreadState.CpuProcessor.PspConfig; if (this.PspConfig.UseCoRoutines) { this.Coroutine = HleThreadManager.Processor.CoroutinePool.CreateCoroutine(this.Name, MainLoop); } else { this.GreenThread = new GreenThread(); GreenThread.InitAndStartStopped(MainLoop); } this.CpuThreadState = CpuThreadState; }
public Atrac(PspEmulatorContext PspEmulatorContext, byte[] Data) { PspEmulatorContext.InjectDependencesTo(this); PrimaryBuffer = HleMemoryManager.GetPartition(Managers.HleMemoryManager.Partitions.User).Allocate(1024); CodecType = CodecType.PSP_MODE_AT_3_PLUS; SetData(Data); }
public override void InitializeComponent() { this.HlePspRtc = PspEmulatorContext.GetInstance <PspRtc>(); }
public override void InitializeComponent() { PspAudio = PspEmulatorContext.GetInstance <PspAudio>(); }
public void _InitializeComponent(PspEmulatorContext PspEmulatorContext) { if (this.PspEmulatorContext != null) throw(new Exception("Can't call _InitializeComponent twice.")); this.PspEmulatorContext = PspEmulatorContext; }
void CreateNewContextAndRemoveOldOne() { ContextInitializedFlag = false; ContextInitialized.Reset(); { // Stops the current context if it has one already. if (PspRunner != null) { PspRunner.StopSynchronized(); PspEmulatorContext.GetInstance<PspMemory>().Dispose(); PspEmulatorContext.GetInstance<GpuImpl>().StopSynchronized(); PspEmulatorContext.GetInstance<PspAudioImpl>().StopSynchronized(); PspRunner = null; PspEmulatorContext = null; GC.Collect(); } foreach (var FileName in new [] { Path.GetDirectoryName(typeof(Program).Assembly.Location) + @"\CSPspEmu.Hle.Modules.dll", Application.ExecutablePath, }) { if (File.Exists(FileName)) { PspConfig.HleModulesDll = Assembly.LoadFile(FileName); break; } } // PspEmulatorContext = new PspEmulatorContext(PspConfig); { PspEmulatorContext.SetInstanceType<GpuImpl, OpenglGpuImpl>(); PspEmulatorContext.SetInstanceType<PspAudioImpl, PspAudioOpenalImpl>(); #if RELEASE PspEmulatorContext.SetInstanceType<PspMemory, FastPspMemory>(); #else PspEmulatorContext.SetInstanceType<PspMemory, NormalPspMemory>(); #endif /* if (PspConfig.UseFastAndUnsaferMemory) { PspEmulatorContext.SetInstanceType<PspMemory, FastPspMemory>(); } else { PspEmulatorContext.SetInstanceType<PspMemory, NormalPspMemory>(); } */ } PspRunner = PspEmulatorContext.GetInstance<PspRunner>(); PspRunner.StartSynchronized(); var GpuImpl = PspEmulatorContext.GetInstance<GpuImpl>(); GpuImpl.InitSynchronizedOnce(); } ContextInitializedFlag = true; ContextInitialized.Set(); }