Stub sys_io for vsh.

This commit is contained in:
clienthax 2021-04-25 15:18:50 +01:00 committed by Megamouse
parent 85b33e9cae
commit c2f0fbcd82
2 changed files with 62 additions and 2 deletions

View file

@ -11,13 +11,26 @@ error_code sys_io_buffer_create(u32 block_count, u32 block_size, u32 blocks, u32
{
sys_io.todo("sys_io_buffer_create(block_count=0x%x, block_size=0x%x, blocks=0x%x, unk1=0x%x, handle=*0x%x)", block_count, block_size, blocks, unk1, handle);
return CELL_OK;
if (!handle)
{
return CELL_EFAULT;
}
if (auto io = idm::make<lv2_io_buf>(block_count, block_size, blocks, unk1))
{
*handle = io;
return CELL_OK;
}
return CELL_ESRCH;
}
error_code sys_io_buffer_destroy(u32 handle)
{
sys_io.todo("sys_io_buffer_destroy(handle=0x%x)", handle);
idm::remove<lv2_io_buf>(handle);
return CELL_OK;
}
@ -25,12 +38,38 @@ error_code sys_io_buffer_allocate(u32 handle, vm::ptr<u32> block)
{
sys_io.todo("sys_io_buffer_allocate(handle=0x%x, block=*0x%x)", handle, block);
return CELL_OK;
if (!block)
{
return CELL_EFAULT;
}
if (auto io = idm::get<lv2_io_buf>(handle))
{
// no idea what we actually need to allocate
if (u32 addr = vm::alloc(io->block_count * io->block_size, vm::main))
{
*block = addr;
return CELL_OK;
}
return CELL_ENOMEM;
}
return CELL_ESRCH;
}
error_code sys_io_buffer_free(u32 handle, u32 block)
{
sys_io.todo("sys_io_buffer_free(handle=0x%x, block=0x%x)", handle, block);
const auto io = idm::get<lv2_io_buf>(handle);
if (!io)
{
return CELL_ESRCH;
}
vm::dealloc(block);
return CELL_OK;
}

View file

@ -2,6 +2,27 @@
#include "Emu/Memory/vm_ptr.h"
struct lv2_io_buf
{
using id_type = lv2_io_buf;
static const u32 id_base = 0x44000000;
static const u32 id_step = 1;
static const u32 id_count = 2048;
const u32 block_count;
const u32 block_size;
const u32 blocks;
const u32 unk1;
lv2_io_buf(u32 block_count, u32 block_size, u32 blocks, u32 unk1)
: block_count(block_count)
, block_size(block_size)
, blocks(blocks)
, unk1(unk1)
{
}
};
// SysCalls
error_code sys_io_buffer_create(u32 block_count, u32 block_size, u32 blocks, u32 unk1, vm::ptr<u32> handle);