//////////////////////// \brief SysGetNextProcessInfo (pidP, pInfo) \param pidP - Pointer to an unsigned integer holding a PID \param pInfo - Pointer to process_info_t struct \return On Success - Return 0 \return No more processes - Return 1 On Failure - Return error as negative value ////////////////////////
| 1827 | /// On Failure - Return error as negative value |
| 1828 | ///////////////////////////// |
| 1829 | long SysGetNextProcessInfo(regs64_t* r){ |
| 1830 | uint64_t* pidP = reinterpret_cast<uint64_t*>(SC_ARG0(r)); |
| 1831 | process_info_t* pInfo = reinterpret_cast<process_info_t*>(SC_ARG1(r)); |
| 1832 | |
| 1833 | process_t* cProcess = Scheduler::GetCurrentProcess(); |
| 1834 | if(!Memory::CheckUsermodePointer(SC_ARG1(r), sizeof(process_info_t), cProcess->addressSpace)){ |
| 1835 | return -EFAULT; |
| 1836 | } |
| 1837 | |
| 1838 | if(!Memory::CheckUsermodePointer(SC_ARG0(r), sizeof(uint64_t), cProcess->addressSpace)){ |
| 1839 | return -EFAULT; |
| 1840 | } |
| 1841 | |
| 1842 | *pidP = Scheduler::GetNextProccessPID(*pidP); |
| 1843 | |
| 1844 | if(!(*pidP)){ |
| 1845 | return 1; // No more processes |
| 1846 | } |
| 1847 | |
| 1848 | process_t* reqProcess; |
| 1849 | if(!(reqProcess = Scheduler::FindProcessByPID(*pidP))){ |
| 1850 | return -EINVAL; |
| 1851 | } |
| 1852 | |
| 1853 | pInfo->pid = *pidP; |
| 1854 | |
| 1855 | pInfo->threadCount = reqProcess->threadCount; |
| 1856 | |
| 1857 | pInfo->uid = reqProcess->uid; |
| 1858 | pInfo->gid = reqProcess->gid; |
| 1859 | |
| 1860 | pInfo->state = reqProcess->state; |
| 1861 | |
| 1862 | strcpy(pInfo->name, reqProcess->name); |
| 1863 | |
| 1864 | pInfo->runningTime = Timer::GetSystemUptime() - reqProcess->creationTime.seconds; |
| 1865 | pInfo->activeUs = reqProcess->activeTicks * 1000000 / Timer::GetFrequency(); |
| 1866 | |
| 1867 | return 0; |
| 1868 | } |
| 1869 | |
| 1870 | ///////////////////////////// |
| 1871 | /// \brief SysReadLink(pathname, buf, bufsize) Read a symbolic link |
nothing calls this directly
no test coverage detected