Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test plz] Yield PPU on disk access operations #6060

Merged
merged 1 commit into from Jun 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
112 changes: 55 additions & 57 deletions rpcs3/Emu/Cell/Modules/cellFs.cpp
Expand Up @@ -11,11 +11,9 @@

#include <mutex>



LOG_CHANNEL(cellFs);

error_code cellFsGetPath(u32 fd, vm::ptr<char> out_path)
error_code cellFsGetPath(ppu_thread& ppu, u32 fd, vm::ptr<char> out_path)
{
cellFs.trace("cellFsGetPath(fd=%d, out_path=*0x%x)", fd, out_path);

Expand All @@ -24,10 +22,10 @@ error_code cellFsGetPath(u32 fd, vm::ptr<char> out_path)
return CELL_EFAULT;
}

return sys_fs_test(6, 0, vm::var<u32>{fd}, sizeof(u32), out_path, 0x420);
return sys_fs_test(ppu, 6, 0, vm::var<u32>{fd}, sizeof(u32), out_path, 0x420);
}

error_code cellFsOpen(vm::cptr<char> path, s32 flags, vm::ptr<u32> fd, vm::cptr<void> arg, u64 size)
error_code cellFsOpen(ppu_thread& ppu, vm::cptr<char> path, s32 flags, vm::ptr<u32> fd, vm::cptr<void> arg, u64 size)
{
cellFs.trace("cellFsOpen(path=%s, flags=%#o, fd=*0x%x, arg=*0x%x, size=0x%llx)", path, flags, fd, arg, size);

Expand All @@ -37,7 +35,7 @@ error_code cellFsOpen(vm::cptr<char> path, s32 flags, vm::ptr<u32> fd, vm::cptr<
}

// TODO
return sys_fs_open(path, flags, fd, flags & CELL_FS_O_CREAT ? CELL_FS_S_IRUSR | CELL_FS_S_IWUSR : 0, arg, size);
return sys_fs_open(ppu, path, flags, fd, flags & CELL_FS_O_CREAT ? CELL_FS_S_IRUSR | CELL_FS_S_IWUSR : 0, arg, size);
}

error_code cellFsOpen2()
Expand All @@ -46,7 +44,7 @@ error_code cellFsOpen2()
return CELL_OK;
}

error_code cellFsSdataOpen(vm::cptr<char> path, s32 flags, vm::ptr<u32> fd, vm::cptr<void> arg, u64 size)
error_code cellFsSdataOpen(ppu_thread& ppu, vm::cptr<char> path, s32 flags, vm::ptr<u32> fd, vm::cptr<void> arg, u64 size)
{
cellFs.trace("cellFsSdataOpen(path=%s, flags=%#o, fd=*0x%x, arg=*0x%x, size=0x%llx)", path, flags, fd, arg, size);

Expand All @@ -55,31 +53,31 @@ error_code cellFsSdataOpen(vm::cptr<char> path, s32 flags, vm::ptr<u32> fd, vm::
return CELL_EINVAL;
}

return cellFsOpen(path, CELL_FS_O_RDONLY, fd, vm::make_var<be_t<u32>[2]>({0x180, 0x10}), 8);
return cellFsOpen(ppu, path, CELL_FS_O_RDONLY, fd, vm::make_var<be_t<u32>[2]>({0x180, 0x10}), 8);
}

error_code cellFsRead(u32 fd, vm::ptr<void> buf, u64 nbytes, vm::ptr<u64> nread)
error_code cellFsRead(ppu_thread& ppu, u32 fd, vm::ptr<void> buf, u64 nbytes, vm::ptr<u64> nread)
{
cellFs.trace("cellFsRead(fd=0x%x, buf=0x%x, nbytes=0x%llx, nread=0x%x)", fd, buf, nbytes, nread);

return sys_fs_read(fd, buf, nbytes, nread ? nread : vm::var<u64>{});
return sys_fs_read(ppu, fd, buf, nbytes, nread ? nread : vm::var<u64>{});
}

error_code cellFsWrite(u32 fd, vm::cptr<void> buf, u64 nbytes, vm::ptr<u64> nwrite)
error_code cellFsWrite(ppu_thread& ppu, u32 fd, vm::cptr<void> buf, u64 nbytes, vm::ptr<u64> nwrite)
{
cellFs.trace("cellFsWrite(fd=0x%x, buf=*0x%x, nbytes=0x%llx, nwrite=*0x%x)", fd, buf, nbytes, nwrite);

return sys_fs_write(fd, buf, nbytes, nwrite ? nwrite : vm::var<u64>{});
return sys_fs_write(ppu, fd, buf, nbytes, nwrite ? nwrite : vm::var<u64>{});
}

error_code cellFsClose(u32 fd)
error_code cellFsClose(ppu_thread& ppu, u32 fd)
{
cellFs.trace("cellFsClose(fd=0x%x)", fd);

return sys_fs_close(fd);
return sys_fs_close(ppu, fd);
}

error_code cellFsOpendir(vm::cptr<char> path, vm::ptr<u32> fd)
error_code cellFsOpendir(ppu_thread& ppu, vm::cptr<char> path, vm::ptr<u32> fd)
{
cellFs.trace("cellFsOpendir(path=%s, fd=*0x%x)", path, fd);

Expand All @@ -89,10 +87,10 @@ error_code cellFsOpendir(vm::cptr<char> path, vm::ptr<u32> fd)
}

// TODO
return sys_fs_opendir(path, fd);
return sys_fs_opendir(ppu, path, fd);
}

error_code cellFsReaddir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<u64> nread)
error_code cellFsReaddir(ppu_thread& ppu, u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<u64> nread)
{
cellFs.trace("cellFsReaddir(fd=0x%x, dir=*0x%x, nread=*0x%x)", fd, dir, nread);

Expand All @@ -101,17 +99,17 @@ error_code cellFsReaddir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<u64> nread)
return CELL_EFAULT;
}

return sys_fs_readdir(fd, dir, nread);
return sys_fs_readdir(ppu, fd, dir, nread);
}

error_code cellFsClosedir(u32 fd)
error_code cellFsClosedir(ppu_thread& ppu, u32 fd)
{
cellFs.trace("cellFsClosedir(fd=0x%x)", fd);

return sys_fs_closedir(fd);
return sys_fs_closedir(ppu, fd);
}

error_code cellFsStat(vm::cptr<char> path, vm::ptr<CellFsStat> sb)
error_code cellFsStat(ppu_thread& ppu, vm::cptr<char> path, vm::ptr<CellFsStat> sb)
{
cellFs.trace("cellFsStat(path=%s, sb=*0x%x)", path, sb);

Expand All @@ -121,14 +119,14 @@ error_code cellFsStat(vm::cptr<char> path, vm::ptr<CellFsStat> sb)
}

// TODO
return sys_fs_stat(path, sb);
return sys_fs_stat(ppu, path, sb);
}

error_code cellFsFstat(u32 fd, vm::ptr<CellFsStat> sb)
error_code cellFsFstat(ppu_thread& ppu, u32 fd, vm::ptr<CellFsStat> sb)
{
cellFs.trace("cellFsFstat(fd=0x%x, sb=*0x%x)", fd, sb);

return sys_fs_fstat(fd, sb);
return sys_fs_fstat(ppu, fd, sb);
}

error_code cellFsLink()
Expand All @@ -137,39 +135,39 @@ error_code cellFsLink()
return CELL_OK;
}

error_code cellFsMkdir(vm::cptr<char> path, s32 mode)
error_code cellFsMkdir(ppu_thread& ppu, vm::cptr<char> path, s32 mode)
{
cellFs.trace("cellFsMkdir(path=%s, mode=%#o)", path, mode);

// TODO
return sys_fs_mkdir(path, mode);
return sys_fs_mkdir(ppu, path, mode);
}

error_code cellFsRename(vm::cptr<char> from, vm::cptr<char> to)
error_code cellFsRename(ppu_thread& ppu, vm::cptr<char> from, vm::cptr<char> to)
{
cellFs.trace("cellFsRename(from=%s, to=%s)", from, to);

// TODO
return sys_fs_rename(from, to);
return sys_fs_rename(ppu, from, to);
}

error_code cellFsRmdir(vm::cptr<char> path)
error_code cellFsRmdir(ppu_thread& ppu, vm::cptr<char> path)
{
cellFs.trace("cellFsRmdir(path=%s)", path);

// TODO
return sys_fs_rmdir(path);
return sys_fs_rmdir(ppu, path);
}

error_code cellFsUnlink(vm::cptr<char> path)
error_code cellFsUnlink(ppu_thread& ppu, vm::cptr<char> path)
{
cellFs.trace("cellFsUnlink(path=%s)", path);

// TODO
return sys_fs_unlink(path);
return sys_fs_unlink(ppu, path);
}

error_code cellFsUtime(vm::cptr<char> path, vm::cptr<CellFsUtimbuf> timep)
error_code cellFsUtime(ppu_thread& ppu, vm::cptr<char> path, vm::cptr<CellFsUtimbuf> timep)
{
cellFs.trace("cellFsUtime(path=%s, timep=*0x%x)", path, timep);

Expand All @@ -179,7 +177,7 @@ error_code cellFsUtime(vm::cptr<char> path, vm::cptr<CellFsUtimbuf> timep)
}

// TODO
return sys_fs_utime(path, timep);
return sys_fs_utime(ppu, path, timep);
}

error_code cellFsAccess()
Expand All @@ -194,7 +192,7 @@ error_code cellFsFcntl()
return CELL_OK;
}

error_code cellFsLseek(u32 fd, s64 offset, u32 whence, vm::ptr<u64> pos)
error_code cellFsLseek(ppu_thread& ppu, u32 fd, s64 offset, u32 whence, vm::ptr<u64> pos)
{
cellFs.trace("cellFsLseek(fd=0x%x, offset=0x%llx, whence=0x%x, pos=*0x%x)", fd, offset, whence, pos);

Expand All @@ -203,7 +201,7 @@ error_code cellFsLseek(u32 fd, s64 offset, u32 whence, vm::ptr<u64> pos)
return CELL_EFAULT;
}

return sys_fs_lseek(fd, offset, whence, pos);
return sys_fs_lseek(ppu, fd, offset, whence, pos);
}

error_code cellFsFdatasync(ppu_thread& ppu, u32 fd)
Expand All @@ -220,7 +218,7 @@ error_code cellFsFsync(ppu_thread& ppu, u32 fd)
return sys_fs_fsync(ppu, fd);
}

error_code cellFsFGetBlockSize(u32 fd, vm::ptr<u64> sector_size, vm::ptr<u64> block_size)
error_code cellFsFGetBlockSize(ppu_thread& ppu, u32 fd, vm::ptr<u64> sector_size, vm::ptr<u64> block_size)
{
cellFs.trace("cellFsFGetBlockSize(fd=0x%x, sector_size=*0x%x, block_size=*0x%x)", fd, sector_size, block_size);

Expand All @@ -229,7 +227,7 @@ error_code cellFsFGetBlockSize(u32 fd, vm::ptr<u64> sector_size, vm::ptr<u64> bl
return CELL_EFAULT;
}

return sys_fs_fget_block_size(fd, sector_size, block_size, vm::var<u64>{}, vm::var<s32>{});
return sys_fs_fget_block_size(ppu, fd, sector_size, block_size, vm::var<u64>{}, vm::var<s32>{});
}

error_code cellFsFGetBlockSize2()
Expand All @@ -238,7 +236,7 @@ error_code cellFsFGetBlockSize2()
return CELL_OK;
}

error_code cellFsGetBlockSize(vm::cptr<char> path, vm::ptr<u64> sector_size, vm::ptr<u64> block_size)
error_code cellFsGetBlockSize(ppu_thread& ppu, vm::cptr<char> path, vm::ptr<u64> sector_size, vm::ptr<u64> block_size)
{
cellFs.trace("cellFsGetBlockSize(path=%s, sector_size=*0x%x, block_size=*0x%x)", path, sector_size, block_size);

Expand All @@ -248,7 +246,7 @@ error_code cellFsGetBlockSize(vm::cptr<char> path, vm::ptr<u64> sector_size, vm:
}

// TODO
return sys_fs_get_block_size(path, sector_size, block_size, vm::var<u64>{});
return sys_fs_get_block_size(ppu, path, sector_size, block_size, vm::var<u64>{});
}

error_code cellFsGetBlockSize2()
Expand Down Expand Up @@ -305,19 +303,19 @@ error_code cellFsLsnRead2()
return CELL_OK;
}

error_code cellFsTruncate(vm::cptr<char> path, u64 size)
error_code cellFsTruncate(ppu_thread& ppu, vm::cptr<char> path, u64 size)
{
cellFs.trace("cellFsTruncate(path=%s, size=0x%llx)", path, size);

// TODO
return sys_fs_truncate(path, size);
return sys_fs_truncate(ppu, path, size);
}

error_code cellFsFtruncate(u32 fd, u64 size)
error_code cellFsFtruncate(ppu_thread& ppu, u32 fd, u64 size)
{
cellFs.trace("cellFsFtruncate(fd=0x%x, size=0x%llx)", fd, size);

return sys_fs_ftruncate(fd, size);
return sys_fs_ftruncate(ppu, fd, size);
}

error_code cellFsSymbolicLink()
Expand All @@ -326,12 +324,12 @@ error_code cellFsSymbolicLink()
return CELL_OK;
}

error_code cellFsChmod(vm::cptr<char> path, s32 mode)
error_code cellFsChmod(ppu_thread& ppu, vm::cptr<char> path, s32 mode)
{
cellFs.trace("cellFsChmod(path=%s, mode=%#o)", path, mode);

// TODO
return sys_fs_chmod(path, mode);
return sys_fs_chmod(ppu, path, mode);
}

error_code cellFsChown()
Expand All @@ -340,7 +338,7 @@ error_code cellFsChown()
return CELL_OK;
}

error_code cellFsGetFreeSize(vm::cptr<char> path, vm::ptr<u32> block_size, vm::ptr<u64> block_count)
error_code cellFsGetFreeSize(ppu_thread& ppu, vm::cptr<char> path, vm::ptr<u32> block_size, vm::ptr<u64> block_count)
{
cellFs.todo("cellFsGetFreeSize(path=%s, block_size=*0x%x, block_count=*0x%x)", path, block_size, block_count);

Expand Down Expand Up @@ -384,7 +382,7 @@ error_code cellFsTruncate2()
return CELL_OK;
}

error_code cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32 entries_size, vm::ptr<u32> data_count)
error_code cellFsGetDirectoryEntries(ppu_thread& ppu, u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32 entries_size, vm::ptr<u32> data_count)
{
cellFs.trace("cellFsGetDirectoryEntries(fd=%d, entries=*0x%x, entries_size=0x%x, data_count=*0x%x)", fd, entries, entries_size, data_count);

Expand All @@ -408,7 +406,7 @@ error_code cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entri
op->arg.ptr = entries;
op->arg.max = entries_size / sizeof(CellFsDirectoryEntry);

const s32 rc = sys_fs_fcntl(fd, 0xe0000012, op.ptr(&lv2_file_op_dir::arg), 0x10);
const s32 rc = sys_fs_fcntl(ppu, fd, 0xe0000012, op.ptr(&lv2_file_op_dir::arg), 0x10);

*data_count = op->arg._size;

Expand All @@ -420,7 +418,7 @@ error_code cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entri
return not_an_error(rc);
}

error_code cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr<void> buf, u64 buffer_size, vm::ptr<u64> nread)
error_code cellFsReadWithOffset(ppu_thread& ppu, u32 fd, u64 offset, vm::ptr<void> buf, u64 buffer_size, vm::ptr<u64> nread)
{
cellFs.trace("cellFsReadWithOffset(fd=%d, offset=0x%llx, buf=*0x%x, buffer_size=0x%llx, nread=*0x%x)", fd, offset, buf, buffer_size, nread);

Expand All @@ -440,7 +438,7 @@ error_code cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr<void> buf, u64 buffe
arg->offset = offset;
arg->size = buffer_size;

const s32 rc = sys_fs_fcntl(fd, 0x8000000a, arg, arg.size());
const s32 rc = sys_fs_fcntl(ppu, fd, 0x8000000a, arg, arg.size());

// Write size read
if (nread)
Expand All @@ -456,7 +454,7 @@ error_code cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr<void> buf, u64 buffe
return not_an_error(rc);
}

error_code cellFsWriteWithOffset(u32 fd, u64 offset, vm::cptr<void> buf, u64 data_size, vm::ptr<u64> nwrite)
error_code cellFsWriteWithOffset(ppu_thread& ppu, u32 fd, u64 offset, vm::cptr<void> buf, u64 data_size, vm::ptr<u64> nwrite)
{
cellFs.trace("cellFsWriteWithOffset(fd=%d, offset=0x%llx, buf=*0x%x, data_size=0x%llx, nwrite=*0x%x)", fd, offset, buf, data_size, nwrite);

Expand All @@ -482,7 +480,7 @@ error_code cellFsWriteWithOffset(u32 fd, u64 offset, vm::cptr<void> buf, u64 dat
arg->offset = offset;
arg->size = data_size;

const s32 rc = sys_fs_fcntl(fd, 0x8000000b, arg, arg.size());
const s32 rc = sys_fs_fcntl(ppu, fd, 0x8000000b, arg, arg.size());

// Write size written
if (nwrite)
Expand All @@ -498,7 +496,7 @@ error_code cellFsWriteWithOffset(u32 fd, u64 offset, vm::cptr<void> buf, u64 dat
return not_an_error(rc);
}

error_code cellFsSdataOpenByFd(u32 mself_fd, s32 flags, vm::ptr<u32> sdata_fd, u64 offset, vm::cptr<void> arg, u64 size)
error_code cellFsSdataOpenByFd(ppu_thread& ppu, u32 mself_fd, s32 flags, vm::ptr<u32> sdata_fd, u64 offset, vm::cptr<void> arg, u64 size)
{
cellFs.trace("cellFsSdataOpenByFd(mself_fd=0x%x, flags=%#o, sdata_fd=*0x%x, offset=0x%llx, arg=*0x%x, size=0x%llx)", mself_fd, flags, sdata_fd, offset, arg, size);

Expand Down Expand Up @@ -530,7 +528,7 @@ error_code cellFsSdataOpenByFd(u32 mself_fd, s32 flags, vm::ptr<u32> sdata_fd, u
ctrl->arg_ptr = arg.addr();
ctrl->arg_size = u32(size);

if (const s32 rc = sys_fs_fcntl(mself_fd, 0x80000009, ctrl, 0x40))
if (const s32 rc = sys_fs_fcntl(ppu, mself_fd, 0x80000009, ctrl, 0x40))
{
return not_an_error(rc);
}
Expand Down Expand Up @@ -601,7 +599,7 @@ error_code cellFsAllocateFileAreaByFdWithInitialData()
return CELL_OK;
}

error_code cellFsAllocateFileAreaWithoutZeroFill(vm::cptr<char> path, u64 size)
error_code cellFsAllocateFileAreaWithoutZeroFill(ppu_thread& ppu, vm::cptr<char> path, u64 size)
{
cellFs.trace("cellFsAllocateFileAreaWithoutZeroFill(path=%s, size=0x%llx)", path, size);

Expand All @@ -620,7 +618,7 @@ error_code cellFsAllocateFileAreaWithoutZeroFill(vm::cptr<char> path, u64 size)
ctrl->out_code = CELL_ENOSYS;

// TODO
if (s32 rc = sys_fs_fcntl(-1, 0xe0000017, ctrl, ctrl->size))
if (s32 rc = sys_fs_fcntl(ppu, -1, 0xe0000017, ctrl, ctrl->size))
{
return not_an_error(rc);
}
Expand Down