Exemplo n.º 1
0
 public virtual void freeStack()
 {
     if (stackSysMemInfo != null)
     {
         Modules.SysMemUserForUserModule.free(stackSysMemInfo);
         stackSysMemInfo = null;
         stackAddr       = 0;
     }
     freeExtendedStack();
 }
Exemplo n.º 2
0
        public virtual SysMemUserForUser.SysMemInfo extendStack(int size)
        {
            SysMemUserForUser.SysMemInfo extendedStackSysMemInfo = Modules.SysMemUserForUserModule.malloc(SysMemUserForUser.USER_PARTITION_ID, string.Format("ThreadMan-ExtendedStack-0x{0:x}-{1}", uid, name), SysMemUserForUser.PSP_SMEM_High, size, 0);
            if (extendedStackSysMemInfos == null)
            {
                extendedStackSysMemInfos = new LinkedList <SysMemUserForUser.SysMemInfo>();
            }
            extendedStackSysMemInfos.Add(extendedStackSysMemInfo);

            return(extendedStackSysMemInfo);
        }
Exemplo n.º 3
0
        public virtual void unload()
        {
            if (memory != null)
            {
                if (Modules.log.DebugEnabled)
                {
                    Modules.Console.WriteLine(string.Format("Freeing 0x{0:X} bytes for HLE module {1}", memory.size, Name));
                }

                Modules.SysMemUserForUserModule.free(memory);
                memory = null;
            }
        }
Exemplo n.º 4
0
        public virtual void freeExtendedStack(SysMemUserForUser.SysMemInfo extendedStackSysMemInfo)
        {
            if (extendedStackSysMemInfos != null)
            {
                if (extendedStackSysMemInfos.Remove(extendedStackSysMemInfo))
                {
                    Modules.SysMemUserForUserModule.free(extendedStackSysMemInfo);
                }

                if (extendedStackSysMemInfos.Count == 0)
                {
                    extendedStackSysMemInfos = null;
                }
            }
        }
Exemplo n.º 5
0
        private void initMemory(Memory mem)
        {
            this.mem = mem;

            memInfo = Modules.SysMemUserForUserModule.malloc(SysMemUserForUser.KERNEL_PARTITION_ID, "UmdBrowserSound", SysMemUserForUser.PSP_SMEM_Low, 0x20000, 0);
            if (memInfo != null)
            {
                samplesAddr = memInfo.addr;
                inputAddr   = memInfo.addr + 0x10000;
            }
            else
            {
                // PSP not yet initialized, use any memory space
                samplesAddr = MemoryMap.START_USERSPACE;
                inputAddr   = MemoryMap.START_USERSPACE + 0x10000;
            }
        }
Exemplo n.º 6
0
        public virtual void load()
        {
            int memoryUsage = MemoryUsage;

            if (memoryUsage > 0)
            {
                if (Modules.log.DebugEnabled)
                {
                    Modules.Console.WriteLine(string.Format("Allocating 0x{0:X} bytes for HLE module {1}", memoryUsage, Name));
                }

                memory = Modules.SysMemUserForUserModule.malloc(SysMemUserForUser.USER_PARTITION_ID, string.Format("Module-{0}", Name), SysMemUserForUser.PSP_SMEM_Low, memoryUsage, 0);
            }
            else
            {
                memory = null;
            }
        }
Exemplo n.º 7
0
        public SceKernelThreadInfo(string name, int entry_addr, int initPriority, int stackSize, int attr, int mpidStack)
        {
            if (stackSize < 512)
            {
                // 512 byte min. (required for interrupts)
                stackSize = 512;
            }
            else
            {
                // 256 byte size alignment.
                stackSize = (stackSize + 0xFF) & ~0xFF;
            }

            if (mpidStack == 0)
            {
                mpidStack = SysMemUserForUser.USER_PARTITION_ID;
            }

            this.name         = name;
            this.entry_addr   = entry_addr;
            this.initPriority = initPriority;
            this.stackSize    = stackSize;
            this.attr         = attr;
            uid = SceUidManager.getNewUid("ThreadMan-thread");
            // Setup the stack.
            int stackMemoryType = (attr & PSP_THREAD_ATTR_LOW_MEM_STACK) != 0 ? SysMemUserForUser.PSP_SMEM_Low : SysMemUserForUser.PSP_SMEM_High;

            stackSysMemInfo = Modules.SysMemUserForUserModule.malloc(mpidStack, string.Format("ThreadMan-Stack-0x{0:x}-{1}", uid, name), stackMemoryType, stackSize, 0);
            if (stackSysMemInfo == null)
            {
                stackAddr = 0;
            }
            else
            {
                stackAddr = stackSysMemInfo.addr;
            }

            // Inherit gpReg.
            gpReg_addr = Emulator.Processor.cpu._gp;
            // Inherit context.
            cpuContext = new CpuState(Emulator.Processor.cpu);
            wait       = new ThreadWaitInfo();
            reset();
        }
Exemplo n.º 8
0
        public virtual void stopSound()
        {
            done = true;
            while (!threadExit)
            {
                Utilities.sleep(1, 0);
            }

            if (mLine != null)
            {
                mLine.close();
            }

            if (memInfo != null)
            {
                Modules.SysMemUserForUserModule.free(memInfo);
                memInfo     = null;
                samplesAddr = 0;
                inputAddr   = 0;
            }
        }