forked from RPCSX/rpcsx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'RPCSX:master' into devel
- Loading branch information
Showing
38 changed files
with
730 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include "KernelAllocator.hpp" | ||
#include "file.hpp" | ||
#include "utils/Rc.hpp" | ||
|
||
namespace orbis { | ||
struct Pipe final : File { | ||
kvector<std::byte> data; | ||
}; | ||
|
||
Ref<Pipe> createPipe(); | ||
} // namespace orbis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "pipe.hpp" | ||
#include "error/ErrorCode.hpp" | ||
#include "file.hpp" | ||
#include "uio.hpp" | ||
#include <span> | ||
#include <thread> | ||
|
||
static orbis::ErrorCode pipe_read(orbis::File *file, orbis::Uio *uio, | ||
orbis::Thread *thread) { | ||
auto pipe = static_cast<orbis::Pipe *>(file); | ||
while (true) { | ||
if (pipe->data.empty()) { | ||
std::this_thread::sleep_for(std::chrono::seconds(1)); | ||
} | ||
|
||
std::lock_guard lock(pipe->mtx); | ||
|
||
if (pipe->data.empty()) { | ||
continue; | ||
} | ||
|
||
for (auto vec : std::span(uio->iov, uio->iovcnt)) { | ||
auto size = std::min<std::size_t>(pipe->data.size(), vec.len); | ||
uio->offset += size; | ||
std::memcpy(vec.base, pipe->data.data(), size); | ||
|
||
if (pipe->data.size() == size) { | ||
break; | ||
} | ||
|
||
std::memmove(pipe->data.data(), pipe->data.data() + size, | ||
pipe->data.size() - size); | ||
pipe->data.resize(pipe->data.size() - size); | ||
} | ||
|
||
break; | ||
} | ||
return {}; | ||
} | ||
|
||
static orbis::ErrorCode pipe_write(orbis::File *file, orbis::Uio *uio, | ||
orbis::Thread *thread) { | ||
auto pipe = static_cast<orbis::Pipe *>(file); | ||
std::lock_guard lock(pipe->mtx); | ||
|
||
for (auto vec : std::span(uio->iov, uio->iovcnt)) { | ||
auto offset = pipe->data.size(); | ||
pipe->data.resize(offset + vec.len); | ||
std::memcpy(pipe->data.data(), vec.base, vec.len); | ||
} | ||
uio->resid = 0; | ||
return {}; | ||
} | ||
|
||
static orbis::FileOps pipe_ops = {.read = pipe_read, .write = pipe_write}; | ||
|
||
orbis::Ref<orbis::Pipe> orbis::createPipe() { | ||
auto result = knew<Pipe>(); | ||
result->ops = &pipe_ops; | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
#include "KernelContext.hpp" | ||
#include "sys/sysproto.hpp" | ||
#include <cstdlib> | ||
#include <unistd.h> | ||
|
||
orbis::SysResult orbis::sys_fork(Thread *thread) { return ErrorCode::NOSYS; } | ||
orbis::SysResult orbis::sys_pdfork(Thread *thread, ptr<sint> fdp, sint flags) { | ||
return ErrorCode::NOSYS; | ||
} | ||
|
||
orbis::SysResult orbis::sys_vfork(Thread *thread) { return ErrorCode::NOSYS; } | ||
orbis::SysResult orbis::sys_rfork(Thread *thread, sint flags) { | ||
if (auto fork = thread->tproc->ops->fork) { | ||
return fork(thread, flags); | ||
} | ||
return ErrorCode::NOSYS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
#include "sys/sysproto.hpp" | ||
#include <pipe.hpp> | ||
|
||
orbis::SysResult orbis::sys_pipe(Thread *thread) { return ErrorCode::NOSYS; } | ||
orbis::SysResult orbis::sys_pipe(Thread *thread) { | ||
auto pipe = createPipe(); | ||
thread->retval[0] = thread->tproc->fileDescriptors.insert(pipe); | ||
thread->retval[1] = thread->tproc->fileDescriptors.insert(pipe); | ||
return {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.