2023-07-03 13:10:16 +02:00
|
|
|
#pragma once
|
|
|
|
|
#include "orbis-config.hpp"
|
2023-07-05 00:43:47 +02:00
|
|
|
|
|
|
|
|
#include "../evf.hpp"
|
2023-07-29 23:44:24 +02:00
|
|
|
#include "../ipmi.hpp"
|
2023-07-17 18:53:48 +02:00
|
|
|
#include "../osem.hpp"
|
2023-07-05 00:43:47 +02:00
|
|
|
#include "../thread/Thread.hpp"
|
|
|
|
|
#include "../thread/types.hpp"
|
|
|
|
|
#include "ProcessState.hpp"
|
2023-07-29 18:53:34 +02:00
|
|
|
#include "orbis/file.hpp"
|
2023-07-03 13:10:16 +02:00
|
|
|
#include "orbis/module/Module.hpp"
|
|
|
|
|
#include "orbis/utils/IdMap.hpp"
|
|
|
|
|
#include "orbis/utils/SharedMutex.hpp"
|
|
|
|
|
|
|
|
|
|
namespace orbis {
|
|
|
|
|
class KernelContext;
|
|
|
|
|
struct Thread;
|
|
|
|
|
struct ProcessOps;
|
|
|
|
|
struct sysentvec;
|
|
|
|
|
|
2023-07-10 03:47:29 +02:00
|
|
|
struct NamedObjInfo {
|
|
|
|
|
void *idptr;
|
|
|
|
|
uint16_t ty;
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-16 17:31:12 +02:00
|
|
|
struct NamedMemoryRange {
|
|
|
|
|
uint64_t begin, end;
|
|
|
|
|
|
|
|
|
|
constexpr bool operator<(const NamedMemoryRange &rhs) const {
|
|
|
|
|
return end <= rhs.begin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend constexpr bool operator<(const NamedMemoryRange &lhs, uint64_t ptr) {
|
|
|
|
|
return lhs.end <= ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend constexpr bool operator<(uint64_t ptr, const NamedMemoryRange &rhs) {
|
|
|
|
|
return ptr < rhs.begin;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-15 18:05:14 +02:00
|
|
|
struct Process final {
|
2023-07-03 13:10:16 +02:00
|
|
|
KernelContext *context = nullptr;
|
|
|
|
|
pid_t pid = -1;
|
|
|
|
|
sysentvec *sysent = nullptr;
|
|
|
|
|
ProcessState state = ProcessState::NEW;
|
|
|
|
|
Process *parentProcess = nullptr;
|
|
|
|
|
shared_mutex mtx;
|
2023-07-05 00:43:47 +02:00
|
|
|
void (*onSysEnter)(Thread *thread, int id, uint64_t *args,
|
|
|
|
|
int argsCount) = nullptr;
|
|
|
|
|
void (*onSysExit)(Thread *thread, int id, uint64_t *args, int argsCount,
|
|
|
|
|
SysResult result) = nullptr;
|
2023-07-03 13:10:16 +02:00
|
|
|
ptr<void> processParam = nullptr;
|
|
|
|
|
uint64_t processParamSize = 0;
|
|
|
|
|
const ProcessOps *ops = nullptr;
|
|
|
|
|
|
|
|
|
|
std::uint64_t nextTlsSlot = 1;
|
|
|
|
|
std::uint64_t lastTlsOffset = 0;
|
|
|
|
|
|
2023-07-05 00:43:47 +02:00
|
|
|
utils::RcIdMap<EventFlag, sint, 4097, 1> evfMap;
|
2023-07-17 18:53:48 +02:00
|
|
|
utils::RcIdMap<Semaphore, sint, 4097, 1> semMap;
|
2023-07-29 23:44:24 +02:00
|
|
|
utils::RcIdMap<IpmiClient, sint, 4097, 1> ipmiClientMap;
|
2023-08-20 14:39:18 +02:00
|
|
|
utils::RcIdMap<IpmiServer, sint, 4097, 1> ipmiServerMap;
|
2023-07-03 13:10:16 +02:00
|
|
|
utils::RcIdMap<Module, ModuleHandle> modulesMap;
|
|
|
|
|
utils::OwningIdMap<Thread, lwpid_t> threadsMap;
|
2023-07-29 18:53:34 +02:00
|
|
|
utils::RcIdMap<orbis::File, sint> fileDescriptors;
|
2023-07-08 15:44:05 +02:00
|
|
|
|
|
|
|
|
// Named objects for debugging
|
|
|
|
|
utils::shared_mutex namedObjMutex;
|
2023-07-08 16:40:10 +02:00
|
|
|
utils::kmap<void *, utils::kstring> namedObjNames;
|
2023-07-15 16:00:47 +02:00
|
|
|
utils::OwningIdMap<NamedObjInfo, uint, 65535, 1> namedObjIds;
|
2023-07-16 17:31:12 +02:00
|
|
|
|
|
|
|
|
// Named memory ranges for debugging
|
|
|
|
|
utils::shared_mutex namedMemMutex;
|
|
|
|
|
utils::kmap<NamedMemoryRange, utils::kstring> namedMem;
|
2023-07-03 13:10:16 +02:00
|
|
|
};
|
|
|
|
|
} // namespace orbis
|