• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Cpu.CpuThreadState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CSPspEmu.Core.Cpu.CpuThreadState的典型用法代码示例。如果您正苦于以下问题:C# CpuThreadState类的具体用法?C# CpuThreadState怎么用?C# CpuThreadState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CpuThreadState类属于CSPspEmu.Core.Cpu命名空间,在下文中一共展示了CpuThreadState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TestMethod1

        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]);
        }
开发者ID:SsJVasto,项目名称:cspspemu,代码行数:26,代码来源:DynarecFunctionCompilerTaskTest.cs


示例2: Allocate

			public void Allocate(CpuThreadState CpuThreadState, int Size, PspPointer* AddressPointer, uint* Timeout, bool HandleCallbacks)
			{
				if (!TryAllocate(CpuThreadState, Size, AddressPointer))
				{
					bool TimedOut = false;

					ThreadManForUser.ThreadManager.Current.SetWaitAndPrepareWakeUp(HleThread.WaitType.Semaphore, "_sceKernelAllocateVplCB", this, (WakeUp) =>
					{
						ThreadManForUser.PspRtc.RegisterTimeout(Timeout, () =>
						{
							TimedOut = true;
							WakeUp();
						});
						WaitList.Add(new WaitVariablePoolItem()
						{
							RequiredSize = Size,
							WakeUp = () => {
								WakeUp();
								Allocate(CpuThreadState, Size, AddressPointer, Timeout, HandleCallbacks);
							},
						});
					}, HandleCallbacks: HandleCallbacks);

					if (TimedOut) throw(new SceKernelException(SceKernelErrors.ERROR_KERNEL_WAIT_TIMEOUT));
				}
			}
开发者ID:shin527,项目名称:cspspemu,代码行数:26,代码来源:ThreadManForUser.Vpl.cs


示例3: sceKernelPollSema

        public int sceKernelPollSema(CpuThreadState CpuThreadState, SemaphoreId SemaphoreId, int Signal)
        {
            var Semaphore = GetSemaphoreById(SemaphoreId);
            if (Signal <= 0) throw(new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_COUNT));
            if (Semaphore.CurrentCount - Signal < 0)
            {
                //ThreadManager.Reschedule();
                CpuThreadState.Yield();
                throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_SEMA_ZERO));
            }
            Semaphore.IncrementCount(-Signal);
            //throw(new NotImplementedException());
            return 0;
            /*
            try {
                PspSemaphore pspSemaphore = uniqueIdFactory.get!PspSemaphore(semaid);

                if (pspSemaphore.info.currentCount - signal < 0) return SceKernelErrors.ERROR_KERNEL_SEMA_ZERO;

                pspSemaphore.info.currentCount -= signal;
                return 0;
            } catch (UniqueIdNotFoundException) {
                return SceKernelErrors.ERROR_KERNEL_NOT_FOUND_SEMAPHORE;
            }
            */
        }
开发者ID:e-COS,项目名称:cspspemu,代码行数:26,代码来源:ThreadManForUser.Semaphores.cs


示例4: ExecuteInterrupt

 public void ExecuteInterrupt(CpuThreadState CpuThreadState)
 {
     if (InterruptEnabled && InterruptFlag)
     {
         IInterruptManager.Interrupt(CpuThreadState);
     }
 }
开发者ID:soywiz,项目名称:cspspemu,代码行数:7,代码来源:CpuProcessor.cs


示例5: sceKernelCreateThread

        public uint sceKernelCreateThread(CpuThreadState CpuThreadState, string Name, uint /*SceKernelThreadEntry*/ EntryPoint, int InitPriority, int StackSize, PspThreadAttributes Attribute, SceKernelThreadOptParam* Option)
        {
            var Thread = HleState.ThreadManager.Create();
            Thread.Name = Name;
            Thread.Info.PriorityCurrent = InitPriority;
            Thread.Info.PriorityInitially = InitPriority;
            Thread.Attribute = Attribute;
            Thread.GP = CpuThreadState.GP;
            Thread.Info.EntryPoint = (SceKernelThreadEntry)EntryPoint;
            Thread.Stack = HleState.MemoryManager.GetPartition(HleMemoryManager.Partitions.User).Allocate(StackSize, MemoryPartition.Anchor.High, Alignment: 0x100);
            if (!Thread.Attribute.HasFlag(PspThreadAttributes.NoFillStack))
            {
                HleState.MemoryManager.Memory.WriteRepeated1(0xFF, Thread.Stack.Low, Thread.Stack.Size);
                //Console.Error.WriteLine("-------------------------------------------------");
                //Console.Error.WriteLine("'{0}', '{1}'", StackSize, Thread.Stack.Size);
                //Console.Error.WriteLine("-------------------------------------------------");
            }
            Thread.Info.StackPointer = Thread.Stack.High;
            Thread.Info.StackSize = StackSize;

            // Used K0 from parent thread.
            // @FAKE. K0 should be preserved between thread calls. Though probably not modified by user modules.
            Thread.CpuThreadState.CopyRegistersFrom(HleState.ThreadManager.Current.CpuThreadState);

            Thread.CpuThreadState.PC = (uint)EntryPoint;
            Thread.CpuThreadState.GP = (uint)CpuThreadState.GP;
            Thread.CpuThreadState.SP = (uint)(Thread.Stack.High);
            Thread.CpuThreadState.RA = (uint)HleEmulatorSpecialAddresses.CODE_PTR_EXIT_THREAD;
            Thread.CurrentStatus = HleThread.Status.Stopped;
            //Thread.CpuThreadState.RA = (uint)0;

            //Console.WriteLine("STACK: {0:X}", Thread.CpuThreadState.SP);

            return (uint)Thread.Id;
        }
开发者ID:mrcmunir,项目名称:cspspemu,代码行数:35,代码来源:ThreadManForUser.Threads.cs


示例6: waitThreadForever

 public void waitThreadForever(CpuThreadState CpuThreadState)
 {
     var SleepThread = HleState.ThreadManager.Current;
     SleepThread.CurrentStatus = HleThread.Status.Waiting;
     SleepThread.CurrentWaitType = HleThread.WaitType.None;
     CpuThreadState.Yield();
 }
开发者ID:mrcmunir,项目名称:cspspemu,代码行数:7,代码来源:Emulator.cs


示例7: LlePspCpu

 public LlePspCpu(string Name, InjectContext InjectContext, CpuProcessor CpuProcessor, uint EntryPoint = 0x1fc00000)
 {
     this.Name = Name;
     //this.CachedGetMethodCache = PspEmulatorContext.GetInstance<CachedGetMethodCache>();
     this.CpuThreadState = new CpuThreadState(CpuProcessor);
     this.EntryPoint = EntryPoint;
 }
开发者ID:soywiz,项目名称:cspspemu,代码行数:7,代码来源:LlePspCpu.cs


示例8: waitThreadForever

 public void waitThreadForever(CpuThreadState CpuThreadState)
 {
     var SleepThread = ThreadManager.Current;
     SleepThread.SetStatus(HleThread.Status.Waiting);
     SleepThread.CurrentWaitType = HleThread.WaitType.None;
     ThreadManager.Yield();
 }
开发者ID:SsJVasto,项目名称:cspspemu,代码行数:7,代码来源:Emulator.cs


示例9: SetArgumentsToCpuThreadState

        public void SetArgumentsToCpuThreadState(CpuThreadState CpuThreadState)
        {
            int GprIndex = 4;
            //int FprIndex = 0;
            Action<int> GprAlign = (int Alignment) =>
            {
                GprIndex = (int)MathUtils.NextAligned((uint)GprIndex, Alignment);
            };
            foreach (var Argument in Arguments)
            {
                var ArgumentType = Argument.GetType();
                if (ArgumentType == typeof(uint))
                {
                    GprAlign(1);
                    CpuThreadState.GPR[GprIndex++] = (int)(uint)Argument;
                }
                else if (ArgumentType == typeof(int))
                {
                    GprAlign(1);
                    CpuThreadState.GPR[GprIndex++] = (int)Argument;
                }
                else
                {
                    throw(new NotImplementedException(String.Format("Can't handle type '{0}'", ArgumentType)));
                }
            }

            CpuThreadState.PC = Function;
            //Console.Error.WriteLine(CpuThreadState);
            //CpuThreadState.DumpRegisters(Console.Error);
        }
开发者ID:mrcmunir,项目名称:cspspemu,代码行数:31,代码来源:HleCallback.cs


示例10: Run

        public void Run()
        {
            var CpuThreadState = new CpuThreadState(CpuProcessor);
            var Dma = new Dma(CpuThreadState);

            Console.SetWindowSize(120, 60);
            Console.SetBufferSize(120, 8000);

            var NandStream = File.OpenRead(NandPath);
            var IplReader = new IplReader(new NandReader(NandStream));
            var Info = IplReader.LoadIplToMemory(new PspMemoryStream(PspMemory));
            uint StartPC = Info.EntryFunction;

            var LLEState = new LLEState();

            Dma.LLEState = LLEState;
            LLEState.GPIO = new LleGPIO();
            LLEState.NAND = new LleNAND(NandStream);
            LLEState.Cpu = new LlePspCpu("CPU", InjectContext, CpuProcessor, StartPC);
            LLEState.Me = new LlePspCpu("ME", InjectContext, CpuProcessor, StartPC);
            LLEState.LleKirk = new LleKirk(PspMemory);
            LLEState.Memory = PspMemory;

            LLEState.Cpu.Start();

            while (true) Thread.Sleep(int.MaxValue);
        }
开发者ID:soywiz,项目名称:cspspemu,代码行数:27,代码来源:Program.cs


示例11: sceKernelChangeThreadPriority

 public int sceKernelChangeThreadPriority(CpuThreadState CpuThreadState, int ThreadId, int Priority)
 {
     GetThreadById(ThreadId).PriorityValue = Priority;
     HleState.ThreadManager.Reschedule();
     CpuThreadState.Yield();
     //throw(new NotImplementedException());
     return 0;
 }
开发者ID:mrcmunir,项目名称:cspspemu,代码行数:8,代码来源:ThreadManForUser.Threads.cs


示例12: Kprintf

        public void Kprintf(string Format, CpuThreadState CpuThreadState)
        {
            var Arguments = new ArgumentReader(CpuThreadState);
            Arguments.LoadInteger(); // Skips format

            ConsoleUtils.SaveRestoreConsoleColor(ConsoleColor.Blue, () =>
            {
                Console.Error.Write("{0}", CStringFormater.Sprintf(Format, Arguments));
            });
        }
开发者ID:e-COS,项目名称:cspspemu,代码行数:10,代码来源:KDebugForKernel.cs


示例13: sceKernelSignalSema

		public int sceKernelSignalSema(CpuThreadState CpuThreadState, SemaphoreId SemaphoreId, int Signal)
		{
			//Console.Error.WriteLine("sceKernelSignalSema!");
			var HleSemaphore = GetSemaphoreById(SemaphoreId);
			if (HleSemaphore.IncrementCount(Signal) > 0)
			{
				CpuThreadState.Yield();
			}
			return 0;
		}
开发者ID:shin527,项目名称:cspspemu,代码行数:10,代码来源:ThreadManForUser.Semaphores.cs


示例14: DebugCurrentThread

 public static void DebugCurrentThread(CpuThreadState CpuThreadState)
 {
     var CpuProcessor = CpuThreadState.CpuProcessor;
     Console.Error.WriteLine("*******************************************");
     Console.Error.WriteLine("* DebugCurrentThread **********************");
     Console.Error.WriteLine("*******************************************");
     CpuProcessor.DebugCurrentThreadEvent();
     Console.Error.WriteLine("*******************************************");
     CpuThreadState.DumpRegisters();
     Console.Error.WriteLine("*******************************************");
 }
开发者ID:SsJVasto,项目名称:cspspemu,代码行数:11,代码来源:CpuProcessor.cs


示例15: sceKernelDeleteSema

        public int sceKernelDeleteSema(CpuThreadState CpuThreadState, SemaphoreId SemaphoreId)
        {
            var HleSemaphore = GetSemaphoreById(SemaphoreId);
            SemaphoreManager.Semaphores.Remove((int)SemaphoreId);
            if (HleSemaphore.IncrementCount(HleSemaphore.SceKernelSemaInfo.MaximumCount) > 0)
            {
                CpuThreadState.Yield();
            }

            return 0;
        }
开发者ID:e-COS,项目名称:cspspemu,代码行数:11,代码来源:ThreadManForUser.Semaphores.cs


示例16: Syscall

		public void Syscall(int Code, CpuThreadState CpuThreadState)
		{
			Action<CpuThreadState, int> Callback;
			if ((Callback = GetSyscall(Code)) != null)
			{
				Callback(CpuThreadState, Code);
			}
			else
			{
				Console.WriteLine("Undefined syscall: {0:X6} at 0x{1:X8}", Code, CpuThreadState.PC);
			}
		}
开发者ID:shin527,项目名称:cspspemu,代码行数:12,代码来源:CpuProcessor.cs


示例17: Syscall

 public void Syscall(int Code, CpuThreadState CpuThreadState)
 {
     Action<int, CpuThreadState> Callback;
     if (RegisteredNativeSyscalls.TryGetValue(Code, out Callback))
     {
         Callback(Code, CpuThreadState);
     }
     else
     {
         Console.WriteLine("Undefined syscall: %06X at 0x%08X".Sprintf(Code, CpuThreadState.PC));
     }
 }
开发者ID:mrcmunir,项目名称:cspspemu,代码行数:12,代码来源:CpuProcessor.cs


示例18: ExecuteQueued

		public int ExecuteQueued(CpuThreadState CpuThreadState, bool MustReschedule)
		{
			int ExecutedCount = 0;

			//Console.WriteLine("ExecuteQueued");
			if (HasScheduledCallbacks)
			{
				//Console.WriteLine("ExecuteQueued.HasScheduledCallbacks!");
				//Console.Error.WriteLine("STARTED CALLBACKS");
				while (HasScheduledCallbacks)
				{
					var HleCallback = DequeueScheduledCallback();

					/*
					var FakeCpuThreadState = new CpuThreadState(CpuProcessor);
					FakeCpuThreadState.CopyRegistersFrom(CpuThreadState);
					HleCallback.SetArgumentsToCpuThreadState(FakeCpuThreadState);

					if (FakeCpuThreadState.PC == 0x88040E0) FakeCpuThreadState.PC = 0x880416C;
					*/
					//Console.WriteLine("ExecuteCallback: PC=0x{0:X}", FakeCpuThreadState.PC);
					//Console.WriteLine("               : A0=0x{0:X}", FakeCpuThreadState.GPR[4]);
					//Console.WriteLine("               : A1=0x{0:X}", FakeCpuThreadState.GPR[5]);
					try
					{
						HleInterop.ExecuteFunctionNow(HleCallback.Function, HleCallback.Arguments);
					}
					catch (Exception Exception)
					{
						Console.Error.WriteLine(Exception);
					}
					finally
					{
						//Console.WriteLine("               : PC=0x{0:X}", FakeCpuThreadState.PC);
						ExecutedCount++;
					}

					//Console.Error.WriteLine("  CALLBACK ENDED : " + HleCallback);
					if (MustReschedule)
					{
						//Console.Error.WriteLine("    RESCHEDULE");
						break;
					}
				}

				ExecutedCount += HleInterop.ExecuteAllQueuedFunctionsNow();
				//Console.Error.WriteLine("ENDED CALLBACKS");
			}

			return ExecutedCount;
		}
开发者ID:shin527,项目名称:cspspemu,代码行数:51,代码来源:HleCallbackManager.cs


示例19: ToNormalizedTypeString

        public static string ToNormalizedTypeString(Type ParameterType, CpuThreadState CpuThreadState, uint Int4, float Float4)
        {
            if (ParameterType == typeof(void))
            {
                return "void";
            }

            if (ParameterType == typeof(string))
            {
                return String.Format("'{0}'", StringFromAddress(CpuThreadState, Int4));
            }

            if (ParameterType == typeof(int))
            {
                return String.Format("{0}", (int)Int4);
            }

            if (ParameterType.IsEnum)
            {
                var Name = ParameterType.GetEnumName(Int4);
                if (Name == null || Name.Length == 0) Name = Int4.ToString();
                return Name;
            }

            if (ParameterType.IsPointer)
            {
                try
                {
                    return "0x%08X".Sprintf(CpuThreadState.CpuProcessor.Memory.PointerToPspAddress((void*)Int4));
                }
                catch (Exception)
                {
                    return String.Format("0x{0:X}", CpuThreadState.CpuProcessor.Memory.PointerToPspAddress((void*)Int4));
                }
            }

            if (ParameterType == typeof(float))
            {
                return String.Format("{0}", Float4);
            }

            try
            {
                return "0x%08X".Sprintf(Int4);
            }
            catch (Exception)
            {
                return String.Format("0x{0:X}", Int4);
            }
        }
开发者ID:mrcmunir,项目名称:cspspemu,代码行数:50,代码来源:HleModuleHost.cs


示例20: TryAllocate

			public bool TryAllocate(CpuThreadState CpuThreadState, int Size, PspPointer* AddressPointer)
			{
				if (Size > Info.PoolSize) throw(new SceKernelException((SceKernelErrors)(-1)));
				try
				{
					var AllocatedSegment = MemoryPartition.Allocate(Size, InternalMemoryAnchor);
					AddressPointer->Address = AllocatedSegment.GetAnchoredAddress(InternalMemoryAnchor);
					return true;
				}
				catch (MemoryPartitionNoMemoryException)
				{
					//AddressPointer->Address = 0;
					return false;
				}
			}
开发者ID:shin527,项目名称:cspspemu,代码行数:15,代码来源:ThreadManForUser.Vpl.cs



注:本文中的CSPspEmu.Core.Cpu.CpuThreadState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# State.GpuStateStruct类代码示例发布时间:2022-05-24
下一篇:
C# CSLE.CLType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap