当前位置: 首页>>代码示例>>C#>>正文


C# Cpu.CpuThreadState类代码示例

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


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


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