sys_fs: yield PPU on disk access ops

This commit is contained in:
Nekotekina 2019-06-08 19:34:55 +03:00
parent e8a516529b
commit 2bc0ea37ab
3 changed files with 180 additions and 138 deletions

View file

@ -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);
@ -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);
@ -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()
@ -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);
@ -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);
@ -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);
@ -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);
@ -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()
@ -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);
@ -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()
@ -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);
@ -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)
@ -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);
@ -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()
@ -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);
@ -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()
@ -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()
@ -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()
@ -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);
@ -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);
@ -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;
@ -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);
@ -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)
@ -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);
@ -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)
@ -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);
@ -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);
}
@ -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);
@ -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);
}