Esempio n. 1
0
 public HleIoDriverMemoryStick(PspMemory Memory, IMemoryStickEventHandler MemoryStickEventHandler,
                               IHleIoDriver HleIoDriver)
     : base(HleIoDriver)
 {
     this.Memory = Memory;
     this.MemoryStickEventHandler = MemoryStickEventHandler;
 }
Esempio n. 2
0
        public static Stream OpenRead(this IHleIoDriver HleIoDriver, string FileName)
        {
            var HleIoDrvFileArg = new HleIoDrvFileArg("none", HleIoDriver, 0, null);

            HleIoDriver.IoOpen(HleIoDrvFileArg, FileName, HleIoFlags.Read, SceMode.All);
            return(HleIoDrvFileArg.GetStream());
        }
Esempio n. 3
0
        /// <summary>
        /// Returns a tuple of Driver/Index/path.
        /// </summary>
        /// <param name="fullPath"></param>
        /// <returns></returns>
        public ParsePathInfo ParsePath(string fullPath)
        {
            //FullPath = FullPath.Replace('\\', '/');

            //Console.Error.WriteLine("FullPath: {0}", FullPath);
            if (fullPath.IndexOf(':') == -1)
            {
                fullPath = CurrentDirectoryPath + "/" + fullPath;
            }

            //Console.Error.WriteLine("FullPath: {0}", FullPath);
            var          match            = new Regex(@"^([a-zA-Z]+)(\d*):(.*)$").Match(fullPath);
            var          driverName       = match.Groups[1].Value.ToLower() + ":";
            var          fileSystemNumber = 0;
            IHleIoDriver hleIoDriver      = null;

            int.TryParse(match.Groups[2].Value, out fileSystemNumber);
            if (!Drivers.TryGetValue(driverName, out hleIoDriver))
            {
                foreach (var driver in Drivers)
                {
                    Console.WriteLine("Available Driver: '{0}'", driver.Key);
                }
                throw(new KeyNotFoundException("Can't find HleIoDriver '" + driverName + "'"));
            }

            return(new ParsePathInfo
            {
                HleIoDrvFileArg = new HleIoDrvFileArg(driverName, hleIoDriver, fileSystemNumber, null),
                LocalPath = match.Groups[3].Value.Replace('\\', '/'),
            });
        }
Esempio n. 4
0
		public HleIoDrvFileArg(string DriverName, IHleIoDriver HleIoDriver, int FileSystemNumber = 0, IDisposable FileArgument = null)
		{
			this.DriverName = DriverName;
			this.HleIoDriver = HleIoDriver;
			this.FileSystemNumber = FileSystemNumber;
			this.FileArgument = FileArgument;
		}
Esempio n. 5
0
        /// <summary>
        /// Returns a tuple of Driver/Index/path.
        /// </summary>
        /// <param name="FullPath"></param>
        /// <returns></returns>
        public ParsePathInfo ParsePath(string FullPath)
        {
            if (FullPath.IndexOf(':') == -1)
            {
                FullPath = CurrentDirectoryPath + "/" + FullPath;
            }
            var          Match            = new Regex(@"^(\w+)(\d+):(.*)$").Match(FullPath);
            var          DriverName       = Match.Groups[1].Value + ":";
            int          FileSystemNumber = 0;
            IHleIoDriver HleIoDriver      = null;

            Int32.TryParse(Match.Groups[2].Value, out FileSystemNumber);
            if (!Drivers.TryGetValue(DriverName, out HleIoDriver))
            {
                throw(new KeyNotFoundException("Can't find HleIoDriver '" + DriverName + "'"));
            }

            return(new ParsePathInfo()
            {
                HleIoDrvFileArg = new HleIoDrvFileArg()
                {
                    HleIoDriver = HleIoDriver,
                    FileSystemNumber = FileSystemNumber,
                    FileArgument = null,
                },
                LocalPath = Match.Groups[3].Value,
            });
        }
Esempio n. 6
0
 public HleIoDrvFileArg(string DriverName, IHleIoDriver HleIoDriver, int FileSystemNumber = 0, IDisposable?FileArgument = null)
 {
     this.DriverName       = DriverName;
     this.HleIoDriver      = HleIoDriver;
     this.FileSystemNumber = FileSystemNumber;
     this.FileArgument     = FileArgument;
 }
Esempio n. 7
0
        public static SceIoStat GetStat(this IHleIoDriver HleIoDriver, string FileName)
        {
            var HleIoDrvFileArg = new HleIoDrvFileArg("none", HleIoDriver, 0, null);
            var SceIoStat       = default(SceIoStat);

            HleIoDriver.IoGetstat(HleIoDrvFileArg, FileName, &SceIoStat);
            return(SceIoStat);
        }
Esempio n. 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="Driver"></param>
 public void SetDriver(string Name, IHleIoDriver Driver)
 {
     //Drivers.Add(Name, Driver);
     Drivers[Name] = Driver;
     try
     {
         Driver.IoInit();
     }
     catch (Exception Exception)
     {
         Console.Error.WriteLine(Exception);
     }
 }
Esempio n. 9
0
 public static bool FileExists(this IHleIoDriver HleIoDriver, string FileName)
 {
     try
     {
         var HleIoDrvFileArg = new HleIoDrvFileArg("none", HleIoDriver, 0, null);
         var SceIoStat       = default(SceIoStat);
         HleIoDriver.IoGetstat(HleIoDrvFileArg, FileName, &SceIoStat);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 10
0
        public static IEnumerable <HleIoDirent> ListDir(this IHleIoDriver HleIoDriver, string Path)
        {
            var HleIoDrvFileArg = new HleIoDrvFileArg("none", HleIoDriver, 0, null);
            var HleIoDirent     = default(HleIoDirent);
            var List            = new List <HleIoDirent>();

            HleIoDriver.IoDopen(HleIoDrvFileArg, Path);
            while (HleIoDriver.IoDread(HleIoDrvFileArg, &HleIoDirent) > 0)
            {
                List.Add(HleIoDirent);
            }
            HleIoDriver.IoDclose(HleIoDrvFileArg);
            return(List);
        }
Esempio n. 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="driver"></param>
 public void SetDriver(string name, IHleIoDriver driver)
 {
     //Console.Error.WriteLine("SetDriver: {0}", Name);
     //Drivers.Add(Name, Driver);
     Drivers[name] = driver;
     try
     {
         driver.IoInit();
     }
     catch (Exception exception)
     {
         Console.Error.WriteLine(exception);
     }
 }
Esempio n. 12
0
        public static IEnumerable <string> ListDirRecursive(this IHleIoDriver HleIoDriver, string Path)
        {
            foreach (var Item in HleIoDriver.ListDir(Path))
            {
                yield return("/" + (Path + "/" + Item.Name).TrimStart('/'));

                if (Item.Stat.Attributes.HasFlag(IOFileModes.Directory))
                {
                    foreach (var InnerItem in HleIoDriver.ListDirRecursive(Path + "/" + Item.Name))
                    {
                        yield return(InnerItem);
                    }
                }
            }
        }
Esempio n. 13
0
        protected string RunExecutableAndGetOutput(bool runTestsViewOut, string pspAutoTestsFolder, string fileName,
                                                   out string capturedOutput, string fileNameBase)
        {
            var outputString = "";

            IHleIoDriver hostDriver = null;

            //Console.WriteLine(FileNameBase);

            InjectContext injectContext = null;

            {
                //var Capture = false;
                var capture = !runTestsViewOut;
                capturedOutput = ConsoleUtils.CaptureOutput(() =>
                {
                    injectContext = PspInjectContext.CreateInjectContext(StoredConfig, test: true);
                    injectContext.SetInstanceType <HleOutputHandler, HleOutputHandlerMock>();

                    var cpuConfig                  = injectContext.GetInstance <CpuConfig>();
                    var hleConfig                  = injectContext.GetInstance <HleConfig>();
                    cpuConfig.DebugSyscalls        = false;
                    cpuConfig.ShowInstructionStats = false;
                    hleConfig.TraceLastSyscalls    = false;
                    hleConfig.DebugSyscalls        = false;

                    //Console.Error.WriteLine("[1]");

                    var start = DateTime.UtcNow;
                    injectContext.GetInstance <HleModuleManager>();
                    var end = DateTime.UtcNow;
                    Console.WriteLine(end - start);

                    //Console.Error.WriteLine("[a]");

                    // GPU -> NULL
                    //PspEmulatorContext.SetInstanceType<GpuImpl>(typeof(GpuImplOpenglEs));
                    injectContext.SetInstanceType <GpuImpl>(typeof(GpuImplNull));

                    var gpuImpl = injectContext.GetInstance <GpuImpl>();
                    //GpuImpl.InitSynchronizedOnce();

                    //Console.Error.WriteLine("[b]");

                    var pspRunner = injectContext.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 = injectContext.GetInstance <HleIoManager>();
                            hostDriver       = hleIoManager.GetDriver("host:");

                            try
                            {
                                hostDriver.IoRemove(null, "/__testoutput.txt");
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                            try
                            {
                                hostDriver.IoRemove(null, "/__testerror.txt");
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }

                            injectContext.GetInstance <PspHleRunningConfig>().FileNameBase = fileNameBase;
                            pspRunner.CpuComponentThread._LoadFile(fileName);
                            //Console.Error.WriteLine("[3]");
                            if (!pspRunner.CpuComponentThread.StoppedEndedEvent.WaitOne(_timeoutTime))
                            {
                                ConsoleUtils.SaveRestoreConsoleColor(ConsoleColor.Red,
                                                                     () => { Console.Error.WriteLine("Timeout!"); });
                            }
                        }
                        catch (Exception e)
                        {
                            Console.Error.WriteLine(e);
                        }
                    }

                    pspRunner.StopSynchronized();
                    GC.Collect();

                    using var testOutput = hostDriver.OpenRead("/__testoutput.txt");
                    outputString         = testOutput.ReadAllContentsAsString();
                },
                                                            capture: capture
                                                            );

                //var HleOutputHandlerMock = (HleOutputHandlerMock)PspEmulatorContext.GetInstance<HleOutputHandler>();
                //OutputString = HleOutputHandlerMock.OutputString;
            }
            injectContext.Dispose();

            return(outputString);
        }
Esempio n. 14
0
 public void Mount(string MountAt, IHleIoDriver HleIoDriver)
 {
     Mounts[MountAt] = HleIoDriver;
 }
Esempio n. 15
0
 public ProxyHleIoDriver(IHleIoDriver ParentDriver)
 {
     this.ParentDriver = ParentDriver;
 }
Esempio n. 16
0
 public HleIoDriverMemoryStick(IHleIoDriver HleIoDriver)
     : base(HleIoDriver)
 {
 }
Esempio n. 17
0
 public ProxyHleIoDriver(IHleIoDriver ParentDriver) => this.ParentDriver = ParentDriver;
 public static IHleIoDriver AsReadonlyHleIoDriver(this IHleIoDriver HleIoDriver)
 {
     return(new ReadonlyHleIoDriver(HleIoDriver));
 }
Esempio n. 19
0
 public HleIoDriverMemoryStick(IHleIoDriver HleIoDriver) : base(HleIoDriver)
 {
 }
Esempio n. 20
0
 public HleIoDriverMemoryStick(PspMemory Memory, IMemoryStickEventHandler MemoryStickEventHandler, IHleIoDriver HleIoDriver)
     : base(HleIoDriver)
 {
     this.Memory = Memory;
     this.MemoryStickEventHandler = MemoryStickEventHandler;
 }
Esempio n. 21
0
 public HleIoDriverMemoryStick(PspEmulatorContext PspEmulatorContext, IHleIoDriver HleIoDriver)
     : base(HleIoDriver)
 {
     PspEmulatorContext.InjectDependencesTo(this);
 }
Esempio n. 22
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="Driver"></param>
 public void SetDriver(string Name, IHleIoDriver Driver)
 {
     //Drivers.Add(Name, Driver);
     Drivers[Name] = Driver;
     try
     {
         Driver.IoInit();
     }
     catch (Exception Exception)
     {
         Console.Error.WriteLine(Exception);
     }
 }
Esempio n. 23
0
 public void Mount(string MountAt, IHleIoDriver HleIoDriver)
 {
     Mounts[MountAt] = HleIoDriver;
 }
Esempio n. 24
0
 public ReadonlyHleIoDriver(IHleIoDriver HleIoDriver)
     : base(HleIoDriver)
 {
 }
 public ReadonlyHleIoDriver(IHleIoDriver HleIoDriver)
     : base(HleIoDriver)
 {
 }