Exemplo n.º 1
0
	s32 send(s32 s, vm::ptr<const char> buf, u32 len, s32 flags)
	{
		sys_net.Warning("send(s=%d, buf_addr=0x%x, len=%d, flags=0x%x)", s, buf.addr(), len, flags);

		int ret = ::send(s, buf.get_ptr(), len, flags);
		*g_lastError = getLastError();
		return ret;
	}
Exemplo n.º 2
0
	s32 setsockopt(s32 s, s32 level, s32 optname, vm::ptr<const char> optval, u32 optlen)
	{
		sys_net.Warning("socket(s=%d, level=%d, optname=%d, optval_addr=0x%x, optlen=%d)", s, level, optname, optval.addr(), optlen);

		int ret = ::setsockopt(s, level, optname, optval.get_ptr(), optlen);
		*g_lastError = getLastError();
		return ret;
	}
Exemplo n.º 3
0
s32 console_write(vm::ptr<char> data, u32 len)
{
	sysPrxForUser.Warning("console_write(data=*0x%x, len=%d)", data, len);

	LOG_NOTICE(TTY, { data.get_ptr(), len });

	return CELL_OK;
}
Exemplo n.º 4
0
vm::ptr<void> _sys_memcpy(vm::ptr<void> dst, vm::cptr<void> src, u32 size)
{
	sysPrxForUser.Log("_sys_memcpy(dst=*0x%x, src=*0x%x, size=0x%x)", dst, src, size);

	memcpy(dst.get_ptr(), src.get_ptr(), size);

	return dst;
}
Exemplo n.º 5
0
s32 cellFsRmdir(vm::ptr<const char> path)
{
	sys_fs->Warning("cellFsRmdir(path=\"%s\")", path.get_ptr());

	LV2_LOCK(0);

	std::string _path = path.get_ptr();

	vfsDir d;
	if (!d.IsExists(_path))
		return CELL_ENOENT;

	if (!d.Remove(_path))
		return CELL_EBUSY;

	return CELL_OK;
}
Exemplo n.º 6
0
s32 _sys_printf(vm::ptr<const char> fmt)
{
	sysPrxForUser->Todo("_sys_printf(fmt_addr=0x%x, ...)", fmt.addr());

	// probably, assertion failed
	sysPrxForUser->Warning("_sys_printf: \n%s", fmt.get_ptr());
	return CELL_OK;
}
Exemplo n.º 7
0
vm::ptr<void> _sys_memset(vm::ptr<void> dst, s32 value, u32 size)
{
	sysPrxForUser.trace("_sys_memset(dst=*0x%x, value=%d, size=0x%x)", dst, value, size);

	std::memset(dst.get_ptr(), value, size);

	return dst;
}
Exemplo n.º 8
0
	void sprintf(ARMv7Thread& cpu, vm::ptr<char> str, vm::cptr<char> fmt, arm_va_args_t va_args)
	{
		sceLibc.warning("sprintf(str=*0x%x, fmt=%s, ...)", str, fmt);

		const std::string& result = arm_fmt(cpu, fmt, va_args.count);
		sceLibc.trace("sprintf() -> '%s'", result);

		::memcpy(str.get_ptr(), result.c_str(), result.size() + 1);
	}
Exemplo n.º 9
0
s32 _sys_printf(vm::ptr<const char> fmt) // va_args...
{
	sysPrxForUser.Todo("_sys_printf(fmt=*0x%x, ...)", fmt);

	// probably, assertion failed
	sysPrxForUser.Fatal("_sys_printf: \n%s", fmt.get_ptr());
	Emu.Pause();
	return CELL_OK;
}
Exemplo n.º 10
0
s32 cellFsUnlink(vm::ptr<const char> path)
{
	sys_fs->Warning("cellFsUnlink(path=\"%s\")", path.get_ptr());

	LV2_LOCK(0);

	std::string _path = path.get_ptr();

	if (vfsDir().IsExists(_path))
		return CELL_EISDIR;

	if (!Emu.GetVFS().ExistsFile(_path))
		return CELL_ENOENT;

	if (!Emu.GetVFS().RemoveFile(_path))
		return CELL_EACCES;
	
	return CELL_OK;
}
Exemplo n.º 11
0
s32 cellFsChmod(vm::ptr<const char> path, u32 mode)
{
	sys_fs->Todo("cellFsChmod(path=\"%s\", mode=0x%x)", path.get_ptr(), mode);

	LV2_LOCK(0);

	// TODO:

	return CELL_OK;
}
Exemplo n.º 12
0
	s32 recv(s32 s, vm::ptr<char> buf, u32 len, s32 flags)
	{
		libnet.warning("recv(s=%d, buf=*0x%x, len=%d, flags=0x%x)", s, buf, len, flags);
		s = g_socketMap[s];

		s32 ret = ::recv(s, buf.get_ptr(), len, flags);
		get_errno() = getLastError();

		return ret;
	}
Exemplo n.º 13
0
	void sprintf(ARMv7Thread& context, vm::ptr<char> str, vm::cptr<char> fmt, armv7_va_args_t va_args)
	{
		sceLibc.warning("sprintf(str=*0x%x, fmt=*0x%x)", str, fmt);
		sceLibc.trace("*** *fmt = '%s'", fmt.get_ptr());

		const std::string& result = armv7_fmt(context, fmt, va_args.g_count, va_args.f_count, va_args.v_count);
		sceLibc.trace("***     -> '%s'", result);

		::memcpy(str.get_ptr(), result.c_str(), result.size() + 1);
	}
Exemplo n.º 14
0
s32 _sys_sprintf(ppu_thread& ppu, vm::ptr<char> buffer, vm::cptr<char> fmt, ppu_va_args_t va_args)
{
	sysPrxForUser.warning("_sys_sprintf(buffer=*0x%x, fmt=%s, ...)", buffer, fmt);

	std::string result = ps3_fmt(ppu, fmt, va_args.count);

	std::memcpy(buffer.get_ptr(), result.c_str(), result.size() + 1);

	return static_cast<s32>(result.size());
}
Exemplo n.º 15
0
s32 sys_fs_truncate(vm::ptr<const char> path, u64 size)
{
	sys_fs.Warning("sys_fs_truncate(path=*0x%x, size=0x%llx)", path, size);
	sys_fs.Warning("*** path = '%s'", path.get_ptr());

	std::string ps3_path = path.get_ptr();

	if (!Emu.GetVFS().ExistsFile(ps3_path))
	{
		return CELL_FS_ENOENT;
	}

	if (!Emu.GetVFS().TruncateFile(ps3_path, size))
	{
		return CELL_FS_EIO; // ???
	}

	return CELL_OK;
}
Exemplo n.º 16
0
s32 sys_fs_get_block_size(vm::ptr<const char> path, vm::ptr<u64> sector_size, vm::ptr<u64> block_size, vm::ptr<u64> arg4)
{
	sys_fs.Todo("sys_fs_get_block_size(path=*0x%x, sector_size=*0x%x, block_size=*0x%x, arg4=*0x%x, arg5=*0x%x)", path, sector_size, block_size, arg4);
	sys_fs.Todo("*** path = '%s'", path.get_ptr());

	*sector_size = 4096; // ?
	*block_size = 4096; // ?

	return CELL_OK;
}
Exemplo n.º 17
0
int cellVdecGetPicture(u32 handle, vm::ptr<const CellVdecPicFormat> format, vm::ptr<u8> outBuff)
{
	cellVdec->Log("cellVdecGetPicture(handle=%d, format_addr=0x%x, outBuff_addr=0x%x)", handle, format.addr(), outBuff.addr());

	std::shared_ptr<VideoDecoder> vdec;
	if (!Emu.GetIdManager().GetIDData(handle, vdec))
	{
		return CELL_VDEC_ERROR_ARG;
	}

	VdecFrame vf;
	if (!vdec->frames.try_pop(vf))
	{
		//std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
		return CELL_VDEC_ERROR_EMPTY;
	}

	if (!vf.data)
	{
		// hack
		return CELL_OK;
	}

	if (outBuff)
	{
		u32 buf_size = a128(av_image_get_buffer_size(vdec->ctx->pix_fmt, vdec->ctx->width, vdec->ctx->height, 1));

		if (format->formatType != CELL_VDEC_PICFMT_YUV420_PLANAR)
		{
			cellVdec->Todo("cellVdecGetPicture: unknown formatType(%d)", (u32)format->formatType);
			return CELL_OK;
		}

		if (format->colorMatrixType != CELL_VDEC_COLOR_MATRIX_TYPE_BT709)
		{
			cellVdec->Todo("cellVdecGetPicture: unknown colorMatrixType(%d)", (u32)format->colorMatrixType);
			return CELL_OK;
		}

		AVFrame& frame = *vf.data;

		// TODO: zero padding bytes

		int err = av_image_copy_to_buffer(outBuff.get_ptr(), buf_size, frame.data, frame.linesize, vdec->ctx->pix_fmt, frame.width, frame.height, 1);
		if (err < 0)
		{
			cellVdec->Error("cellVdecGetPicture: av_image_copy_to_buffer failed (err=0x%x)", err);
			Emu.Pause();
		}
	}

	av_frame_unref(vf.data);
	av_frame_free(&vf.data);
	return CELL_OK;
}
Exemplo n.º 18
0
s32 cellFsStat(vm::ptr<const char> path, vm::ptr<CellFsStat> sb)
{
	sys_fs->Warning("cellFsStat(path=\"%s\", sb_addr=0x%x)", path.get_ptr(), sb.addr());

	LV2_LOCK(0);

	const std::string _path = path.get_ptr();

	sb->st_mode = 
		CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR |
		CELL_FS_S_IRGRP | CELL_FS_S_IWGRP | CELL_FS_S_IXGRP |
		CELL_FS_S_IROTH | CELL_FS_S_IWOTH | CELL_FS_S_IXOTH;

	sb->st_uid = 0;
	sb->st_gid = 0;
	sb->st_atime_ = 0; //TODO
	sb->st_mtime_ = 0; //TODO
	sb->st_ctime_ = 0; //TODO
	sb->st_blksize = 4096;

	{
		vfsDir dir(_path);
		if(dir.IsOpened())
		{
			sb->st_mode |= CELL_FS_S_IFDIR;
			return CELL_OK;
		}
	}

	{
		vfsFile f(_path);
		if(f.IsOpened())
		{
			sb->st_mode |= CELL_FS_S_IFREG;
			sb->st_size = f.GetSize();
			return CELL_OK;
		}
	}

	sys_fs->Warning("cellFsStat: \"%s\" not found.", path.get_ptr());
	return CELL_ENOENT;
}
Exemplo n.º 19
0
s32 sys_fs_unlink(vm::ptr<const char> path)
{
	sys_fs.Warning("sys_fs_unlink(path=*0x%x)", path);
	sys_fs.Warning("*** path = '%s'", path.get_ptr());

	std::string ps3_path = path.get_ptr();

	if (!Emu.GetVFS().ExistsFile(ps3_path))
	{
		return CELL_FS_ENOENT;
	}

	if (!Emu.GetVFS().RemoveFile(ps3_path))
	{
		return CELL_FS_EIO; // ???
	}

	sys_fs.Notice("sys_fs_unlink(): file '%s' deleted", path.get_ptr());
	return CELL_OK;
}
Exemplo n.º 20
0
s32 sys_fs_rmdir(vm::ptr<const char> path)
{
	sys_fs.Warning("sys_fs_rmdir(path=*0x%x)", path);
	sys_fs.Warning("*** path = '%s'", path.get_ptr());

	std::string ps3_path = path.get_ptr();

	if (!Emu.GetVFS().ExistsDir(ps3_path))
	{
		return CELL_FS_ENOENT;
	}

	if (!Emu.GetVFS().RemoveDir(ps3_path))
	{
		return CELL_FS_EIO; // ???
	}

	sys_fs.Notice("sys_fs_rmdir(): directory '%s' removed", path.get_ptr());
	return CELL_OK;
}
Exemplo n.º 21
0
s32 sys_fs_mkdir(vm::ptr<const char> path, s32 mode)
{
	sys_fs.Warning("sys_fs_mkdir(path=*0x%x, mode=%#o)", path, mode);
	sys_fs.Warning("*** path = '%s'", path.get_ptr());

	std::string ps3_path = path.get_ptr();

	if (Emu.GetVFS().ExistsDir(ps3_path))
	{
		return CELL_FS_EEXIST;
	}

	if (!Emu.GetVFS().CreatePath(ps3_path))
	{
		return CELL_FS_EIO; // ???
	}

	sys_fs.Notice("sys_fs_mkdir(): directory '%s' created", path.get_ptr());
	return CELL_OK;
}
Exemplo n.º 22
0
s32 console_write(vm::ptr<char> data, u32 len)
{
	sysPrxForUser.warning("console_write(data=*0x%x, len=%d)", data, len);

	if (g_tty)
	{
		g_tty.write(data.get_ptr(), len);
	}

	return CELL_OK;
}
Exemplo n.º 23
0
int sys_raw_spu_load(s32 id, vm::ptr<const char> path, vm::ptr<be_t<u32>> entry)
{
	sysPrxForUser->Warning("sys_raw_spu_load(id=0x%x, path_addr=0x%x('%s'), entry_addr=0x%x)", 
		id, path.addr(), path.get_ptr(), entry.addr());

	vfsFile f(path.get_ptr());
	if(!f.IsOpened())
	{
		sysPrxForUser->Error("sys_raw_spu_load error: '%s' not found!", path.get_ptr());
		return CELL_ENOENT;
	}

	ELFLoader l(f);
	l.LoadInfo();
	l.LoadData(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id);

	*entry = l.GetEntry();

	return CELL_OK;
}
Exemplo n.º 24
0
s32 cellHttpUtilBuildUri(vm::cptr<CellHttpUri> uri, vm::ptr<char> buf, u32 len, vm::ptr<u32> required, s32 flags)
{
	cellHttpUtil.todo("cellHttpUtilBuildUri(uri=*0x%x, buf=*0x%x, len=%d, required=*0x%x, flags=%d)", uri, buf, len, required, flags);

	// TODO

	const std::string& result = fmt::format("%s://%s:%s@%s:%d/%s", uri->scheme, uri->username, uri->password, uri->hostname, uri->port, uri->path);
	std::memcpy(buf.get_ptr(), result.c_str(), result.size() + 1);

	return CELL_OK;
}
Exemplo n.º 25
0
	s32 sendto(s32 s, vm::cptr<char> buf, u32 len, s32 flags, vm::ptr<sys_net_sockaddr> addr, u32 addrlen)
	{
		sys_net.Warning("sendto(s=%d, buf=*0x%x, len=%d, flags=0x%x, addr=*0x%x, addrlen=%d)", s, buf, len, flags, addr, addrlen);

		sockaddr _addr;
		memcpy(&_addr, addr.get_ptr(), sizeof(sockaddr));
		_addr.sa_family = addr->sa_family;
		int ret = ::sendto(s, buf.get_ptr(), len, flags, &_addr, addrlen);
		*g_lastError = getLastError();
		return ret;
	}
Exemplo n.º 26
0
s32 _sys_snprintf(PPUThread& CPU, vm::ptr<char> dst, u32 count, vm::ptr<const char> fmt) // va_args...
{
	sysPrxForUser.Warning("_sys_snprintf(dst=*0x%x, count=%d, fmt=*0x%x, ...)", dst, count, fmt);

	std::string result = ps3_fmt(CPU, fmt, 3, 0, 0);

	sysPrxForUser.Warning("*** '%s' -> '%s'", fmt.get_ptr(), result);

	if (!count)
	{
		return 0; // ???
	}
	else
	{
		count = (u32)std::min<size_t>(count - 1, result.size());

		memcpy(dst.get_ptr(), result.c_str(), count);
		dst[count] = 0;
		return count;
	}
}
Exemplo n.º 27
0
	s32 connect(s32 s, vm::ptr<sys_net_sockaddr_in> addr, u32 addrlen)
	{
		sys_net.Warning("connect(s=%d, family=*0x%x, addrlen=%d)", s, addr, addrlen);
		sockaddr_in saddr;
		memcpy(&saddr, addr.get_ptr(), sizeof(sockaddr_in));
		saddr.sin_family = addr->sin_family;
		const char *ipaddr = inet_ntoa(saddr.sin_addr);
		sys_net.Warning("connecting on %s to port %d", ipaddr, ntohs(saddr.sin_port));
		int ret = ::connect(s, (const sockaddr *)&saddr, addrlen);
		*g_lastError = getLastError();
		return ret;
	}
Exemplo n.º 28
0
	s32 recvfrom(s32 s, vm::ptr<char> buf, u32 len, s32 flags, vm::ptr<sockaddr> addr, vm::ptr<u32> paddrlen)
	{
		libnet.warning("recvfrom(s=%d, buf=*0x%x, len=%d, flags=0x%x, addr=*0x%x, paddrlen=*0x%x)", s, buf, len, flags, addr, paddrlen);
		std::shared_ptr<sys_net_socket> sock = idm::get<sys_net_socket>(s);

		::sockaddr _addr;
		::socklen_t _paddrlen;

		memcpy(&_addr, addr.get_ptr(), sizeof(::sockaddr));
		_addr.sa_family = addr->sa_family;
		s32 ret = ::recvfrom(sock->s, buf.get_ptr(), len, flags, &_addr, &_paddrlen);
		*paddrlen = _paddrlen;

		if (ret < 0)
		{
			libnet.error("recvfrom(): error %d", get_errno() = get_last_error());
			return -1;
		}

		return ret;
	}
Exemplo n.º 29
0
s32 cellFsGetBlockSize(vm::ptr<const char> path, vm::ptr<u64> sector_size, vm::ptr<u64> block_size)
{
	sys_fs->Warning("cellFsGetBlockSize(file='%s', sector_size_addr=0x%x, block_size_addr=0x%x)",
		path.get_ptr(), sector_size.addr(), block_size.addr());

	LV2_LOCK(0);

	*sector_size = 4096; // ?
	*block_size = 4096; // ?

	return CELL_OK;
}
Exemplo n.º 30
0
s32 sys_ppu_thread_rename(u64 thread_id, vm::ptr<const char> name)
{
	sys_ppu_thread.Log("sys_ppu_thread_rename(thread_id=%d, name_addr=0x%x('%s'))", thread_id, name.addr(), name.get_ptr());

	CPUThread* thr = Emu.GetCPU().GetThread(thread_id);
	if (!thr) {
		return CELL_ESRCH;
	}

	thr->SetThreadName(name.get_ptr());
	return CELL_OK;
}