[orbis-kernel] impi: implement server ops

stub mkdir/rmdir syscalls
This commit is contained in:
DH 2023-08-20 15:39:18 +03:00
parent ca58c03eb6
commit 7ea6f3d91a
6 changed files with 76 additions and 6 deletions

View File

@ -106,10 +106,7 @@ public:
return {};
}
std::pair<IpmiServer *, bool> createIpmiServer(utils::kstring name,
std::uint32_t attrs,
std::int32_t initCount,
std::int32_t maxCount) {
std::pair<IpmiServer *, bool> createIpmiServer(utils::kstring name) {
std::lock_guard lock(m_sem_mtx);
auto [it, inserted] = mIpmiServers.try_emplace(std::move(name), nullptr);
if (inserted) {

View File

@ -30,6 +30,8 @@ struct FileOps {
ErrorCode (*stat)(File *file, Stat *sb, Thread *thread) = nullptr;
ErrorCode (*mkdir)(File *file, const char *path, std::int32_t mode) = nullptr;
// TODO: chown
// TODO: chmod

View File

@ -60,6 +60,7 @@ struct Process final {
utils::RcIdMap<EventFlag, sint, 4097, 1> evfMap;
utils::RcIdMap<Semaphore, sint, 4097, 1> semMap;
utils::RcIdMap<IpmiClient, sint, 4097, 1> ipmiClientMap;
utils::RcIdMap<IpmiServer, sint, 4097, 1> ipmiServerMap;
utils::RcIdMap<Module, ModuleHandle> modulesMap;
utils::OwningIdMap<Thread, lwpid_t> threadsMap;
utils::RcIdMap<orbis::File, sint> fileDescriptors;

View File

@ -40,6 +40,8 @@ struct ProcessOps {
Ref<File> *file);
SysResult (*shm_open)(Thread *thread, const char *path, sint flags, sint mode,
Ref<File> *file);
SysResult (*mkdir)(Thread *thread, ptr<const char> path, sint mode);
SysResult (*rmdir)(Thread *thread, ptr<const char> path) = nullptr;
SysResult (*blockpool_open)(Thread *thread, Ref<File> *file);
SysResult (*blockpool_map)(Thread *thread, caddr_t addr, size_t len,
sint prot, sint flags);

View File

@ -977,6 +977,19 @@ struct IpmiSyncCallParams {
orbis::uint32_t resultCount;
};
struct IpmiCreateServerParams {
orbis::uint64_t arg0;
orbis::ptr<char> name;
orbis::uint64_t arg2;
};
struct IpmiClientConnectParams {
orbis::ptr<char> arg0;
orbis::ptr<char> name;
orbis::ptr<char> arg2;
orbis::ptr<char> arg3;
};
static_assert(sizeof(IpmiSyncCallParams) == 0x30);
orbis::SysResult orbis::sys_ipmimgr_call(Thread *thread, uint op, uint kid,
@ -985,6 +998,36 @@ orbis::SysResult orbis::sys_ipmimgr_call(Thread *thread, uint op, uint kid,
ORBIS_LOG_TODO("sys_ipmimgr_call", op, kid, result, params, paramsSz, arg6);
thread->where();
if (op == kImpiCreateServer) {
if (paramsSz != sizeof(IpmiCreateServerParams)) {
return ErrorCode::INVAL;
}
auto createParams = (ptr<IpmiCreateServerParams>)params;
ORBIS_LOG_TODO("IPMI: create server", createParams->arg0,
createParams->name, createParams->arg2);
auto [server, inserted] = g_context.createIpmiServer(createParams->name);
if (!inserted) {
return ErrorCode::EXIST;
}
auto id = thread->tproc->ipmiServerMap.insert(server);
return uwrite<uint>(result, id);
}
if (op == 0x10) {
// IPMI server start?
return uwrite<uint>(result, 0);
}
if (op == 0x201) {
// IPMI server receive packet?
return uwrite<uint>(result, 0x80020023);
}
if (op == kIpmiCreateClient) {
if (paramsSz != sizeof(IpmiCreateClientParams)) {
return ErrorCode::INVAL;
@ -1029,7 +1072,13 @@ orbis::SysResult orbis::sys_ipmimgr_call(Thread *thread, uint op, uint kid,
}
if (op == 0x400) {
ORBIS_LOG_TODO("IMPI: connect?");
if (paramsSz != sizeof(IpmiClientConnectParams)) {
return ErrorCode::INVAL;
}
auto connectParams = (ptr<IpmiClientConnectParams>)params;
ORBIS_LOG_TODO("IMPI: connect?", connectParams->arg0, connectParams->name,
connectParams->arg2, connectParams->arg3);
if (result) {
return uwrite<uint>(result, 0);
}

View File

@ -292,13 +292,32 @@ orbis::SysResult orbis::sys_renameat(Thread *thread, sint oldfd, ptr<char> old,
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_mkdir(Thread *thread, ptr<char> path, sint mode) {
if (auto mkdir = thread->tproc->ops->mkdir) {
return mkdir(thread, path, mode);
}
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_mkdirat(Thread *thread, sint fd, ptr<char> path,
mode_t mode) {
return ErrorCode::NOSYS;
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
if (file == nullptr) {
return ErrorCode::BADF;
}
auto mkdir = file->ops->mkdir;
if (mkdir == nullptr) {
return ErrorCode::NOTSUP;
}
std::lock_guard lock(file->mtx);
return mkdir(file.get(), path, mode);
}
orbis::SysResult orbis::sys_rmdir(Thread *thread, ptr<char> path) {
if (auto rmdir = thread->tproc->ops->rmdir) {
return rmdir(thread, path);
}
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_getdirentries(Thread *thread, sint fd,