Beispiel #1
0
        public static Int32 Open(IntPtr winHandle)
        {
            try
            {
                int ret = 0;

                Log_Info("Open");

                if (DEV9Header.config.Hdd.Contains(Path.DirectorySeparatorChar))
                {
                    ret = dev9.Open(DEV9Header.config.Hdd);
                }
                else
                {
                    ret = dev9.Open(iniFolderPath + Path.DirectorySeparatorChar + DEV9Header.config.Hdd);
                }

                if (ret == 0)
                {
                    Log_Info("Open ok");
                }
                else
                {
                    CLR_PSE_PluginLog.MsgBoxErrorTrapper(new Exception("Open Failed"));
                }

                return(ret);
            }
            catch (Exception e)
            {
                CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
                return(-1);
            }
        }
Beispiel #2
0
        private static void LogInit()
        {
            //Not all log sources are configuable
            //As such, not all log sources are listed here

            //Set all configurable sources to show on console
            CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.Test);
            CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.Dev9);
            CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.SPEED);
            CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.SMAP);
            CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.ATA);
            CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.Winsock);
            CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.NetAdapter);
            CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.UDPSession);
            CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.DNSPacket);
            CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.DNSSession);
            //All sources go to the log file by default

            CLR_PSE_PluginLog.SetStdLogLevel(ConfigLogging.ToSourceLevel(DEV9Header.config.LogLevelConsole));
            CLR_PSE_PluginLog.SetFileLevel(ConfigLogging.ToSourceLevel(DEV9Header.config.LogLevelFile));

            CLR_PSE_PluginLog.SetSourceLogLevel(ConfigLogging.ToSourceLevel(DEV9Header.config.EnableLogging.Test), (int)DEV9LogSources.Test);
            CLR_PSE_PluginLog.SetSourceLogLevel(ConfigLogging.ToSourceLevel(DEV9Header.config.EnableLogging.DEV9), (int)DEV9LogSources.Dev9);
            CLR_PSE_PluginLog.SetSourceLogLevel(ConfigLogging.ToSourceLevel(DEV9Header.config.EnableLogging.SPEED), (int)DEV9LogSources.SPEED);
            CLR_PSE_PluginLog.SetSourceLogLevel(ConfigLogging.ToSourceLevel(DEV9Header.config.EnableLogging.SMAP), (int)DEV9LogSources.SMAP);
            CLR_PSE_PluginLog.SetSourceLogLevel(ConfigLogging.ToSourceLevel(DEV9Header.config.EnableLogging.ATA), (int)DEV9LogSources.ATA);
            CLR_PSE_PluginLog.SetSourceLogLevel(ConfigLogging.ToSourceLevel(DEV9Header.config.EnableLogging.Winsock), (int)DEV9LogSources.Winsock);
            CLR_PSE_PluginLog.SetSourceLogLevel(ConfigLogging.ToSourceLevel(DEV9Header.config.EnableLogging.NetAdapter), (int)DEV9LogSources.NetAdapter);
            CLR_PSE_PluginLog.SetSourceLogLevel(ConfigLogging.ToSourceLevel(DEV9Header.config.EnableLogging.UDPSession), (int)DEV9LogSources.UDPSession);
            CLR_PSE_PluginLog.SetSourceLogLevel(ConfigLogging.ToSourceLevel(DEV9Header.config.EnableLogging.DNSPacket), (int)DEV9LogSources.DNSPacket);
            CLR_PSE_PluginLog.SetSourceLogLevel(ConfigLogging.ToSourceLevel(DEV9Header.config.EnableLogging.DNSSession), (int)DEV9LogSources.DNSSession);
        }
Beispiel #3
0
        public static void SaveConf(string iniFolderPath, string iniFileName)
        {
            CLR_PSE_PluginLog.WriteLine(TraceEventType.Verbose, (int)DEV9LogSources.PluginInterface, "Save Config");

            iniFolderPath = iniFolderPath.TrimEnd(Path.DirectorySeparatorChar);
            iniFolderPath = iniFolderPath.TrimEnd(Path.AltDirectorySeparatorChar);

            string filePath = iniFolderPath + Path.DirectorySeparatorChar + iniFileName;

            DataContractSerializer ConfSerializer = new DataContractSerializer(typeof(ConfigFile));

            var settings = new XmlWriterSettings()
            {
                Indent      = true,
                IndentChars = "\t"
            };

            FileStream fileWriter = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite);

            using (XmlWriter xmlWriter = XmlWriter.Create(fileWriter, settings))
            {
                ConfSerializer.WriteObject(xmlWriter, DEV9Header.config);
            }
            fileWriter.Close();
            CLR_PSE_PluginLog.WriteLine(TraceEventType.Verbose, (int)DEV9LogSources.PluginInterface, "Done");
        }
Beispiel #4
0
        public static Int32 Init()
        {
            try
            {
                LogSetup();
#if DEBUG
                CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.PluginInterface);
                //CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.TCPSession);
                //Info is default
                CLR_PSE_PluginLog.SetFileLevel(SourceLevels.All);
                //CLR_PSE_PluginLog.SetSourceLogLevel(SourceLevels.All, (int)DEV9LogSources.ATA);
                //CLR_PSE_PluginLog.SetSourceLogLevel(SourceLevels.All, (int)DEV9LogSources.TCPSession);
                CLR_PSE_PluginLog.SetSourceLogLevel(SourceLevels.All, (int)DEV9LogSources.Dev9);
                CLR_PSE_PluginLog.SetSourceLogLevel(SourceLevels.All, (int)DEV9LogSources.SMAP);
#endif

                ConfigFile.LoadConf(iniFolderPath, "CLR_DEV9.ini");
                Log_Info("Config Loaded");
                LogInit();
                Log_Info("Init");
                dev9 = new DEV9.DEV9_State();
                Log_Info("Init ok");

                hasInit = true;
                return(0);
            }
            catch (Exception e) when(Log_Fatal(e))
            {
                throw;
            }
            catch (Exception) when(tryAvoidThrow)
            {
                return(-1);
            }
        }
Beispiel #5
0
        public static void LoadConf(string iniFolderPath, string iniFileName)
        {
            CLR_PSE_PluginLog.WriteLine(TraceEventType.Verbose, (int)DEV9LogSources.PluginInterface, "Load Config");

            iniFolderPath = iniFolderPath.TrimEnd(Path.DirectorySeparatorChar);
            iniFolderPath = iniFolderPath.TrimEnd(Path.AltDirectorySeparatorChar);

            string filePath = iniFolderPath + Path.DirectorySeparatorChar + iniFileName;

            if (File.Exists(filePath))
            {
                DataContractSerializer ConfSerializer = new DataContractSerializer(typeof(ConfigFile));
                FileStream             Reader         = new FileStream(filePath, FileMode.Open);
                DEV9Header.config = (ConfigFile)ConfSerializer.ReadObject(Reader);
                Reader.Close();
                //Update from old config
                if (DEV9Header.config.Eth == "winsock")
                {
                    DEV9Header.config.Eth = DEV9Header.ETH_DEF;
                }
                CLR_PSE_PluginLog.WriteLine(TraceEventType.Verbose, (int)DEV9LogSources.PluginInterface, "Done");
                return;
            }
            CLR_PSE_PluginLog.WriteLine(TraceEventType.Verbose, (int)DEV9LogSources.PluginInterface, "No Config, Create Default");
            DEV9Header.config = new ConfigFile();

            SaveConf(iniFolderPath, iniFileName);
        }
Beispiel #6
0
 private static void LogInit()
 {
     //Log to info to console
     CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.Test, (int)DEV9LogSources.Test);
     CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.DEV9, (int)DEV9LogSources.Dev9);
     CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.SPEED, (int)DEV9LogSources.SPEED);
     CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.SMAP, (int)DEV9LogSources.SMAP);
     CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.ATA, (int)DEV9LogSources.ATA);
     CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.Winsock, (int)DEV9LogSources.Winsock);
     CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.NetAdapter, (int)DEV9LogSources.NetAdapter);
     CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.UDPSession, (int)DEV9LogSources.UDPSession);
     CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.DNSPacket, (int)DEV9LogSources.DNSPacket);
     CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.DNSSession, (int)DEV9LogSources.DNSSession);
     //Log Trace to file
     CLR_PSE_PluginLog.SetSourceLogLevel(DEV9Header.config.EnableTracing.Test ? SourceLevels.Verbose : SourceLevels.Information, (int)DEV9LogSources.Test);
     CLR_PSE_PluginLog.SetSourceLogLevel(DEV9Header.config.EnableTracing.DEV9 ? SourceLevels.Verbose : SourceLevels.Information, (int)DEV9LogSources.Dev9);
     CLR_PSE_PluginLog.SetSourceLogLevel(DEV9Header.config.EnableTracing.SPEED ? SourceLevels.Verbose : SourceLevels.Information, (int)DEV9LogSources.SPEED);
     CLR_PSE_PluginLog.SetSourceLogLevel(DEV9Header.config.EnableTracing.SMAP ? SourceLevels.Verbose : SourceLevels.Information, (int)DEV9LogSources.SMAP);
     CLR_PSE_PluginLog.SetSourceLogLevel(DEV9Header.config.EnableTracing.ATA ? SourceLevels.Verbose : SourceLevels.Information, (int)DEV9LogSources.ATA);
     CLR_PSE_PluginLog.SetSourceLogLevel(DEV9Header.config.EnableTracing.Winsock ? SourceLevels.Verbose : SourceLevels.Information, (int)DEV9LogSources.Winsock);
     CLR_PSE_PluginLog.SetSourceLogLevel(DEV9Header.config.EnableTracing.NetAdapter ? SourceLevels.Verbose : SourceLevels.Information, (int)DEV9LogSources.NetAdapter);
     CLR_PSE_PluginLog.SetSourceLogLevel(DEV9Header.config.EnableTracing.UDPSession ? SourceLevels.Verbose : SourceLevels.Information, (int)DEV9LogSources.UDPSession);
     CLR_PSE_PluginLog.SetSourceLogLevel(DEV9Header.config.EnableTracing.DNSPacket ? SourceLevels.Verbose : SourceLevels.Information, (int)DEV9LogSources.DNSPacket);
     CLR_PSE_PluginLog.SetSourceLogLevel(DEV9Header.config.EnableTracing.DNSSession ? SourceLevels.Verbose : SourceLevels.Information, (int)DEV9LogSources.DNSSession);
 }
Beispiel #7
0
        public static Int32 Init()
        {
            try
            {
                LogSetup();
#if DEBUG
                CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.PluginInterface);
                //CLR_PSE_PluginLog.SetSourceUseStdOut(true, (int)DEV9LogSources.TCPSession);
                //Info is defualt
                CLR_PSE_PluginLog.SetFileLevel(SourceLevels.All);
                //CLR_PSE_PluginLog.SetSourceLogLevel(SourceLevels.All, (int)DEV9LogSources.ATA);
                //CLR_PSE_PluginLog.SetSourceLogLevel(SourceLevels.All, (int)DEV9LogSources.TCPSession);
                CLR_PSE_PluginLog.SetSourceLogLevel(SourceLevels.All, (int)DEV9LogSources.Dev9);
                CLR_PSE_PluginLog.SetSourceLogLevel(SourceLevels.All, (int)DEV9LogSources.SMAP);
#endif

                ConfigFile.LoadConf(iniFolderPath, "CLR_DEV9.ini");
                Log_Info("Config Loaded");
                LogInit();
                Log_Info("Init");
                dev9 = new DEV9.DEV9_State();
                Log_Info("Init ok");
                return(0);
            }
            catch (Exception e)
            {
                CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
                return(-1);
            }
        }
Beispiel #8
0
 public static void Configure()
 {
     try
     {
         //Config can be called without init
         //logging is setup in init()
         //So we need to check if logging is
         //active, incase of errors dealing
         //with plugin config
         if (!hasInit)
         {
             LogSetup();
         }
         ConfigFile.LoadConf(iniFolderPath, "CLR_DEV9.ini");
         if (!hasInit)
         {
             LogInit();
         }
         ConfigFile.DoConfig(iniFolderPath, "CLR_DEV9.ini");
         ConfigFile.SaveConf(iniFolderPath, "CLR_DEV9.ini");
         if (!hasInit)
         {
             CLR_PSE_PluginLog.Close();
         }
     }
     catch (Exception e) when(Log_Fatal(e))
     {
         throw;
     }
 }
Beispiel #9
0
 public static void Close()
 {
     try
     {
         dev9.Close();
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
         throw;
     }
 }
Beispiel #10
0
 public static void DEV9write32(uint addr, uint value)
 {
     try
     {
         dev9.DEV9_Write32(addr, value);
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
         throw;
     }
 }
Beispiel #11
0
 public static uint DEV9read32(uint addr)
 {
     try
     {
         return(dev9.DEV9_Read32(addr));
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
         throw;
     }
 }
Beispiel #12
0
 public static void DEV9irqCallback(CLR_CyclesCallback callback)
 {
     try
     {
         DEV9Header.DEV9irq = callback;
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
         throw;
     }
 }
Beispiel #13
0
 public static void SetSettingsDir(string dir)
 {
     try
     {
         iniFolderPath = dir;
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
         throw;
     }
 }
Beispiel #14
0
        private static void LogSetup()
        {
            //some legwork to setup the logger
            Dictionary <ushort, string>  logSources = new Dictionary <ushort, string>();
            IEnumerable <DEV9LogSources> sources    = Enum.GetValues(typeof(DEV9LogSources)).Cast <DEV9LogSources>();

            foreach (DEV9LogSources source in sources)
            {
                logSources.Add((ushort)source, source.ToString());
            }
            CLR_PSE_PluginLog.Open(logFolderPath, "DEV9_CLR.log", "CLR_DEV9", logSources);
        }
Beispiel #15
0
 public static void DEV9async(uint cycles)
 {
     try
     {
         dev9.DEV9_Async(cycles);
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
         throw;
     }
 }
Beispiel #16
0
 public static int _DEV9irqHandler()
 {
     try
     {
         return(dev9._DEV9irqHandler());
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
         throw;
     }
 }
Beispiel #17
0
 unsafe public static void DEV9writeDMA8Mem(byte *memPointer, int size)
 {
     try
     {
         System.IO.UnmanagedMemoryStream pMem = new System.IO.UnmanagedMemoryStream(memPointer, size, size, System.IO.FileAccess.Read);
         dev9.DEV9_WriteDMA8Mem(pMem, size);
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
         throw;
     }
 }
Beispiel #18
0
 public static void SetLogDir(string dir)
 {
     try
     {
         logFolderPath = dir;
         //LogInit();
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
         throw;
     }
 }
Beispiel #19
0
 public static void Configure()
 {
     try
     {
         LogInit();
         ConfigFile.LoadConf(iniFolderPath, "CLR_DEV9.ini");
         ConfigFile.DoConfig(iniFolderPath, "CLR_DEV9.ini");
         ConfigFile.SaveConf(iniFolderPath, "CLR_DEV9.ini");
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
         throw;
     }
 }
Beispiel #20
0
 private static void LogInit()
 {
     if (doLog)
     {
         CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.Test, (int)DEV9LogSources.Test);
         CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.DEV9, (int)DEV9LogSources.Dev9);
         CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.SPEED, (int)DEV9LogSources.SPEED);
         CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.SMAP, (int)DEV9LogSources.SMAP);
         CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.ATA, (int)DEV9LogSources.ATA);
         CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.Winsock, (int)DEV9LogSources.Winsock);
         CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.NetAdapter, (int)DEV9LogSources.NetAdapter);
         CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.UDPSession, (int)DEV9LogSources.UDPSession);
         CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.DNSPacket, (int)DEV9LogSources.DNSPacket);
         CLR_PSE_PluginLog.SetSourceUseStdOut(DEV9Header.config.EnableLogging.DNSSession, (int)DEV9LogSources.DNSSession);
         doLog = false;
     }
 }
Beispiel #21
0
        public static void LoadConf(string iniFolderPath, string iniFileName)
        {
            CLR_PSE_PluginLog.WriteLine(TraceEventType.Verbose, (int)DEV9LogSources.PluginInterface, "Load Config");

            iniFolderPath = iniFolderPath.TrimEnd(Path.DirectorySeparatorChar);
            iniFolderPath = iniFolderPath.TrimEnd(Path.AltDirectorySeparatorChar);

            string filePath = iniFolderPath + Path.DirectorySeparatorChar + iniFileName;

            if (File.Exists(filePath))
            {
                DataContractSerializer ConfSerializer = new DataContractSerializer(typeof(ConfigFile));
                FileStream             Reader         = new FileStream(filePath, FileMode.Open);
                try
                {
                    DEV9Header.config = (ConfigFile)ConfSerializer.ReadObject(Reader);
                    Reader.Close();
                }
                catch (System.Exception e)
                {
                    Reader.Close();

                    CLR_PSE_PluginLog.WriteLine(TraceEventType.Error, (int)DEV9LogSources.PluginInterface, e.Message + System.Environment.NewLine + e.StackTrace);
                    CLR_PSE_PluginLog.WriteLine(TraceEventType.Error, (int)DEV9LogSources.PluginInterface, "Failed to Load Config File, Replace With Default");
                    //Invalid config, overwrite
                    DEV9Header.config = new ConfigFile();
                    SaveConf(iniFolderPath, iniFileName);
                    return;
                }
                //Update from old config
                if (DEV9Header.config.Eth == "winsock")
                {
                    DEV9Header.config.Eth = DEV9Header.ETH_DEF;
                }
                CLR_PSE_PluginLog.WriteLine(TraceEventType.Verbose, (int)DEV9LogSources.PluginInterface, "Done");
                return;
            }
            CLR_PSE_PluginLog.WriteLine(TraceEventType.Verbose, (int)DEV9LogSources.PluginInterface, "No Config, Create Default");
            DEV9Header.config = new ConfigFile();

            SaveConf(iniFolderPath, iniFileName);
        }
Beispiel #22
0
 public static CLR_IRQHandler DEV9irqHandler()
 {
     try
     {
         // Pass our handler to pcsx2.
         if (irqHandle.IsAllocated)
         {
             irqHandle.Free(); //allow garbage collection
         }
         Log_Info("Get IRQ");
         CLR_IRQHandler fp = new CLR_IRQHandler(_DEV9irqHandler);
         irqHandle = GCHandle.Alloc(fp); //prevent GC
         return(fp);
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
         throw;
     }
 }
Beispiel #23
0
        public static void Shutdown()
        {
            try
            {
                Log_Info("Shutdown");
                CLR_PSE_PluginLog.Close();
                //PluginLog.Close(); //fclose(dev9Log);

                if (irqHandle.IsAllocated)
                {
                    irqHandle.Free(); //allow garbage collection
                }
                //Do dispose()? (of what?)
                hasInit = false;
            }
            catch (Exception e) when(Log_Fatal(e))
            {
                throw;
            }
        }
Beispiel #24
0
        public static void Shutdown()
        {
            try
            {
                Log_Info("Shutdown");
                CLR_PSE_PluginLog.Close();
                //PluginLog.Close(); //fclose(dev9Log);

                if (irqHandle.IsAllocated)
                {
                    irqHandle.Free(); //allow garbage collection
                }
                //Do dispose()? (of what?)
            }
            catch (Exception e)
            {
                CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
                throw;
            }
        }
Beispiel #25
0
 //freeze
 //config
 //about
 public static int Test()
 {
     try
     {
         CLR_PSE_Version_PCSX2 minVer = new CLR_PSE_Version_PCSX2(1, 3, 1);
         if (CLR_PSE.EmuName != "PCSX2")
         {
             return(0); //Hope it works
         }
         if (CLR_PSE.EmuVersion >= minVer)
         {
             return(0);
         }
         else
         {
             return(-1);
         }
     }
     catch (Exception e)
     {
         CLR_PSE_PluginLog.MsgBoxErrorTrapper(e);
         return(1);
     }
 }
Beispiel #26
0
 //Always return false to avoid catching exception
 private static bool Log_Fatal(Exception ex)
 {
     CLR_PSE_PluginLog.MsgBoxErrorTrapper(ex);
     return(false);
 }
Beispiel #27
0
 private static void Log_Verb(string str)
 {
     CLR_PSE_PluginLog.WriteLine(TraceEventType.Verbose, (int)DEV9LogSources.PluginInterface, str);
 }
Beispiel #28
0
 private static void Log_Info(string str)
 {
     CLR_PSE_PluginLog.WriteLine(TraceEventType.Information, (int)DEV9LogSources.PluginInterface, str);
 }