diff --git a/Utilities/SQueue.h b/Utilities/SQueue.h index 9aa7e58356..83d7adc3dd 100644 --- a/Utilities/SQueue.h +++ b/Utilities/SQueue.h @@ -1,5 +1,7 @@ #pragma once +#include "Utilities/SMutex.h" + template class SQueue { diff --git a/rpcs3/Crypto/key_vault.cpp b/rpcs3/Crypto/key_vault.cpp index 8565addb4d..90bd043a09 100644 --- a/rpcs3/Crypto/key_vault.cpp +++ b/rpcs3/Crypto/key_vault.cpp @@ -1,6 +1,20 @@ #include "stdafx.h" +#include "utils.h" +#include "aes.h" #include "key_vault.h" +SELF_KEY::SELF_KEY(u64 ver, u16 rev, u32 type, const std::string& e, const std::string& r, const std::string& pb, const std::string& pr, u32 ct) +{ + version = ver; + revision = rev; + self_type = type; + hex_to_bytes(erk, e.c_str()); + hex_to_bytes(riv, r.c_str()); + hex_to_bytes(pub, pb.c_str()); + hex_to_bytes(priv, pr.c_str()); + curve_type = ct; +} + KeyVault::KeyVault() { } diff --git a/rpcs3/Crypto/key_vault.h b/rpcs3/Crypto/key_vault.h index 3f78228e9e..d5fabaf829 100644 --- a/rpcs3/Crypto/key_vault.h +++ b/rpcs3/Crypto/key_vault.h @@ -1,5 +1,4 @@ #pragma once -#include "utils.h" enum SELF_KEY_TYPE { KEY_LV0 = 1, @@ -22,17 +21,7 @@ struct SELF_KEY { u8 priv[0x15]; u32 curve_type; - SELF_KEY(u64 ver, u16 rev, u32 type, const std::string& e, const std::string& r, const std::string& pb, const std::string& pr, u32 ct) - { - version = ver; - revision = rev; - self_type = type; - hex_to_bytes(erk, e.c_str()); - hex_to_bytes(riv, r.c_str()); - hex_to_bytes(pub, pb.c_str()); - hex_to_bytes(priv, pr.c_str()); - curve_type = ct; - } + SELF_KEY(u64 ver, u16 rev, u32 type, const std::string& e, const std::string& r, const std::string& pb, const std::string& pr, u32 ct); }; static u8 PKG_AES_KEY[0x10] = { diff --git a/rpcs3/Crypto/unedat.cpp b/rpcs3/Crypto/unedat.cpp index 94c997e745..9c4c96414e 100644 --- a/rpcs3/Crypto/unedat.cpp +++ b/rpcs3/Crypto/unedat.cpp @@ -1,4 +1,6 @@ #include "stdafx.h" +#include "utils.h" +#include "key_vault.h" #include "unedat.h" #include "Utilities/Log.h" diff --git a/rpcs3/Crypto/unedat.h b/rpcs3/Crypto/unedat.h index 990f8deca3..7efc8b3808 100644 --- a/rpcs3/Crypto/unedat.h +++ b/rpcs3/Crypto/unedat.h @@ -1,6 +1,4 @@ #pragma once -#include "utils.h" -#include "key_vault.h" #define SDAT_FLAG 0x01000000 #define EDAT_COMPRESSED_FLAG 0x00000001 diff --git a/rpcs3/Crypto/unpkg.cpp b/rpcs3/Crypto/unpkg.cpp index c08a3b5eab..f762f35804 100644 --- a/rpcs3/Crypto/unpkg.cpp +++ b/rpcs3/Crypto/unpkg.cpp @@ -1,4 +1,8 @@ #include "stdafx.h" +#include "utils.h" +#include "aes.h" +#include "sha1.h" +#include "key_vault.h" #include "unpkg.h" #include diff --git a/rpcs3/Crypto/unpkg.h b/rpcs3/Crypto/unpkg.h index 6a0e7bda28..886ffe3216 100644 --- a/rpcs3/Crypto/unpkg.h +++ b/rpcs3/Crypto/unpkg.h @@ -1,6 +1,4 @@ #pragma once -#include "utils.h" -#include "key_vault.h" // Constants #define PKG_HEADER_SIZE 0xC0 //sizeof(pkg_header) + sizeof(pkg_unk_checksum) diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index d03091dae1..10cc0200c7 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -1,8 +1,317 @@ #include "stdafx.h" #include "Utilities/Log.h" +#include "aes.h" +#include "sha1.h" +#include "utils.h" #include "Emu/FS/vfsLocalFile.h" #include "unself.h" +#include +#include + +void AppInfo::Load(vfsStream& f) +{ + authid = Read64(f); + vendor_id = Read32(f); + self_type = Read32(f); + version = Read64(f); + padding = Read64(f); +} + +void AppInfo::Show() +{ + LOG_NOTICE(LOADER, "AuthID: 0x%llx", authid); + LOG_NOTICE(LOADER, "VendorID: 0x%08x", vendor_id); + LOG_NOTICE(LOADER, "SELF type: 0x%08x", self_type); + LOG_NOTICE(LOADER, "Version: 0x%llx", version); +} + +void SectionInfo::Load(vfsStream& f) +{ + offset = Read64(f); + size = Read64(f); + compressed = Read32(f); + unknown1 = Read32(f); + unknown2 = Read32(f); + encrypted = Read32(f); +} + +void SectionInfo::Show() +{ + LOG_NOTICE(LOADER, "Offset: 0x%llx", offset); + LOG_NOTICE(LOADER, "Size: 0x%llx", size); + LOG_NOTICE(LOADER, "Compressed: 0x%08x", compressed); + LOG_NOTICE(LOADER, "Unknown1: 0x%08x", unknown1); + LOG_NOTICE(LOADER, "Unknown2: 0x%08x", unknown2); + LOG_NOTICE(LOADER, "Encrypted: 0x%08x", encrypted); +} + +void SCEVersionInfo::Load(vfsStream& f) +{ + subheader_type = Read32(f); + present = Read32(f); + size = Read32(f); + unknown = Read32(f); +} + +void SCEVersionInfo::Show() +{ + LOG_NOTICE(LOADER, "Sub-header type: 0x%08x", subheader_type); + LOG_NOTICE(LOADER, "Present: 0x%08x", present); + LOG_NOTICE(LOADER, "Size: 0x%08x", size); + LOG_NOTICE(LOADER, "Unknown: 0x%08x", unknown); +} + +void ControlInfo::Load(vfsStream& f) +{ + type = Read32(f); + size = Read32(f); + next = Read64(f); + + if (type == 1) + { + control_flags.ctrl_flag1 = Read32(f); + control_flags.unknown1 = Read32(f); + control_flags.unknown2 = Read32(f); + control_flags.unknown3 = Read32(f); + control_flags.unknown4 = Read32(f); + control_flags.unknown5 = Read32(f); + control_flags.unknown6 = Read32(f); + control_flags.unknown7 = Read32(f); + } + else if (type == 2) + { + if (size == 0x30) + { + f.Read(file_digest_30.digest, 20); + file_digest_30.unknown = Read64(f); + } + else if (size == 0x40) + { + f.Read(file_digest_40.digest1, 20); + f.Read(file_digest_40.digest2, 20); + file_digest_40.unknown = Read64(f); + } + } + else if (type == 3) + { + npdrm.magic = Read32(f); + npdrm.unknown1 = Read32(f); + npdrm.license = Read32(f); + npdrm.type = Read32(f); + f.Read(npdrm.content_id, 48); + f.Read(npdrm.digest, 16); + f.Read(npdrm.invdigest, 16); + f.Read(npdrm.xordigest, 16); + npdrm.unknown2 = Read64(f); + npdrm.unknown3 = Read64(f); + } +} + +void ControlInfo::Show() +{ + LOG_NOTICE(LOADER, "Type: 0x%08x", type); + LOG_NOTICE(LOADER, "Size: 0x%08x", size); + LOG_NOTICE(LOADER, "Next: 0x%llx", next); + + if (type == 1) + { + LOG_NOTICE(LOADER, "Control flag 1: 0x%08x", control_flags.ctrl_flag1); + LOG_NOTICE(LOADER, "Unknown1: 0x%08x", control_flags.unknown1); + LOG_NOTICE(LOADER, "Unknown2: 0x%08x", control_flags.unknown2); + LOG_NOTICE(LOADER, "Unknown3: 0x%08x", control_flags.unknown3); + LOG_NOTICE(LOADER, "Unknown4: 0x%08x", control_flags.unknown4); + LOG_NOTICE(LOADER, "Unknown5: 0x%08x", control_flags.unknown5); + LOG_NOTICE(LOADER, "Unknown6: 0x%08x", control_flags.unknown6); + LOG_NOTICE(LOADER, "Unknown7: 0x%08x", control_flags.unknown7); + } + else if (type == 2) + { + if (size == 0x30) + { + std::string digest_str; + for (int i = 0; i < 20; i++) + digest_str += fmt::Format("%02x", file_digest_30.digest[i]); + + LOG_NOTICE(LOADER, "Digest: %s", digest_str.c_str()); + LOG_NOTICE(LOADER, "Unknown: 0x%llx", file_digest_30.unknown); + } + else if (size == 0x40) + { + std::string digest_str1; + std::string digest_str2; + for (int i = 0; i < 20; i++) + { + digest_str1 += fmt::Format("%02x", file_digest_40.digest1[i]); + digest_str2 += fmt::Format("%02x", file_digest_40.digest2[i]); + } + + LOG_NOTICE(LOADER, "Digest1: %s", digest_str1.c_str()); + LOG_NOTICE(LOADER, "Digest2: %s", digest_str2.c_str()); + LOG_NOTICE(LOADER, "Unknown: 0x%llx", file_digest_40.unknown); + } + } + else if (type == 3) + { + std::string contentid_str; + std::string digest_str; + std::string invdigest_str; + std::string xordigest_str; + for (int i = 0; i < 48; i++) + contentid_str += fmt::Format("%02x", npdrm.content_id[i]); + for (int i = 0; i < 16; i++) + { + digest_str += fmt::Format("%02x", npdrm.digest[i]); + invdigest_str += fmt::Format("%02x", npdrm.invdigest[i]); + xordigest_str += fmt::Format("%02x", npdrm.xordigest[i]); + } + + LOG_NOTICE(LOADER, "Magic: 0x%08x", npdrm.magic); + LOG_NOTICE(LOADER, "Unknown1: 0x%08x", npdrm.unknown1); + LOG_NOTICE(LOADER, "License: 0x%08x", npdrm.license); + LOG_NOTICE(LOADER, "Type: 0x%08x", npdrm.type); + LOG_NOTICE(LOADER, "ContentID: %s", contentid_str.c_str()); + LOG_NOTICE(LOADER, "Digest: %s", digest_str.c_str()); + LOG_NOTICE(LOADER, "Inverse digest: %s", invdigest_str.c_str()); + LOG_NOTICE(LOADER, "XOR digest: %s", xordigest_str.c_str()); + LOG_NOTICE(LOADER, "Unknown2: 0x%llx", npdrm.unknown2); + LOG_NOTICE(LOADER, "Unknown3: 0x%llx", npdrm.unknown3); + } +} + +void MetadataInfo::Load(u8* in) +{ + memcpy(key, in, 0x10); + memcpy(key_pad, in + 0x10, 0x10); + memcpy(iv, in + 0x20, 0x10); + memcpy(iv_pad, in + 0x30, 0x10); +} + +void MetadataInfo::Show() +{ + std::string key_str; + std::string key_pad_str; + std::string iv_str; + std::string iv_pad_str; + for (int i = 0; i < 0x10; i++) + { + key_str += fmt::Format("%02x", key[i]); + key_pad_str += fmt::Format("%02x", key_pad[i]); + iv_str += fmt::Format("%02x", iv[i]); + iv_pad_str += fmt::Format("%02x", iv_pad[i]); + } + + LOG_NOTICE(LOADER, "Key: %s", key_str.c_str()); + LOG_NOTICE(LOADER, "Key pad: %s", key_pad_str.c_str()); + LOG_NOTICE(LOADER, "IV: %s", iv_str.c_str()); + LOG_NOTICE(LOADER, "IV pad: %s", iv_pad_str.c_str()); +} + +void MetadataHeader::Load(u8* in) +{ + memcpy(&signature_input_length, in, 8); + memcpy(&unknown1, in + 8, 4); + memcpy(§ion_count, in + 12, 4); + memcpy(&key_count, in + 16, 4); + memcpy(&opt_header_size, in + 20, 4); + memcpy(&unknown2, in + 24, 4); + memcpy(&unknown3, in + 28, 4); + + // Endian swap. + signature_input_length = swap64(signature_input_length); + unknown1 = swap32(unknown1); + section_count = swap32(section_count); + key_count = swap32(key_count); + opt_header_size = swap32(opt_header_size); + unknown2 = swap32(unknown2); + unknown3 = swap32(unknown3); +} + +void MetadataHeader::Show() +{ + LOG_NOTICE(LOADER, "Signature input length: 0x%llx", signature_input_length); + LOG_NOTICE(LOADER, "Unknown1: 0x%08x", unknown1); + LOG_NOTICE(LOADER, "Section count: 0x%08x", section_count); + LOG_NOTICE(LOADER, "Key count: 0x%08x", key_count); + LOG_NOTICE(LOADER, "Optional header size: 0x%08x", opt_header_size); + LOG_NOTICE(LOADER, "Unknown2: 0x%08x", unknown2); + LOG_NOTICE(LOADER, "Unknown3: 0x%08x", unknown3); +} + +void MetadataSectionHeader::Load(u8* in) +{ + memcpy(&data_offset, in, 8); + memcpy(&data_size, in + 8, 8); + memcpy(&type, in + 16, 4); + memcpy(&program_idx, in + 20, 4); + memcpy(&hashed, in + 24, 4); + memcpy(&sha1_idx, in + 28, 4); + memcpy(&encrypted, in + 32, 4); + memcpy(&key_idx, in + 36, 4); + memcpy(&iv_idx, in + 40, 4); + memcpy(&compressed, in + 44, 4); + + // Endian swap. + data_offset = swap64(data_offset); + data_size = swap64(data_size); + type = swap32(type); + program_idx = swap32(program_idx); + hashed = swap32(hashed); + sha1_idx = swap32(sha1_idx); + encrypted = swap32(encrypted); + key_idx = swap32(key_idx); + iv_idx = swap32(iv_idx); + compressed = swap32(compressed); +} + +void MetadataSectionHeader::Show() +{ + LOG_NOTICE(LOADER, "Data offset: 0x%llx", data_offset); + LOG_NOTICE(LOADER, "Data size: 0x%llx", data_size); + LOG_NOTICE(LOADER, "Type: 0x%08x", type); + LOG_NOTICE(LOADER, "Program index: 0x%08x", program_idx); + LOG_NOTICE(LOADER, "Hashed: 0x%08x", hashed); + LOG_NOTICE(LOADER, "SHA1 index: 0x%08x", sha1_idx); + LOG_NOTICE(LOADER, "Encrypted: 0x%08x", encrypted); + LOG_NOTICE(LOADER, "Key index: 0x%08x", key_idx); + LOG_NOTICE(LOADER, "IV index: 0x%08x", iv_idx); + LOG_NOTICE(LOADER, "Compressed: 0x%08x", compressed); +} + +void SectionHash::Load(vfsStream& f) +{ + f.Read(sha1, 20); + f.Read(padding, 12); + f.Read(hmac_key, 64); +} + +void CapabilitiesInfo::Load(vfsStream& f) +{ + type = Read32(f); + capabilities_size = Read32(f); + next = Read32(f); + unknown1 = Read32(f); + unknown2 = Read64(f); + unknown3 = Read64(f); + flags = Read64(f); + unknown4 = Read32(f); + unknown5 = Read32(f); +} + +void Signature::Load(vfsStream& f) +{ + f.Read(r, 21); + f.Read(s, 21); + f.Read(padding, 6); +} + +void SelfSection::Load(vfsStream& f) +{ + *data = Read32(f); + size = Read64(f); + offset = Read64(f); +} + SELFDecrypter::SELFDecrypter(vfsStream& s) : self_f(s), key_v(), data_buf_length(0) { diff --git a/rpcs3/Crypto/unself.h b/rpcs3/Crypto/unself.h index 860d71e826..947904e13a 100644 --- a/rpcs3/Crypto/unself.h +++ b/rpcs3/Crypto/unself.h @@ -1,10 +1,8 @@ #pragma once -#include "utils.h" -#include "key_vault.h" -#include "Loader/ELF.h" + #include "Loader/SELF.h" -#include -#include +#include "Loader/ELF.h" +#include "key_vault.h" struct AppInfo { @@ -14,22 +12,9 @@ struct AppInfo u64 version; u64 padding; - void Load(vfsStream& f) - { - authid = Read64(f); - vendor_id = Read32(f); - self_type = Read32(f); - version = Read64(f); - padding = Read64(f); - } + void Load(vfsStream& f); - void Show() - { - LOG_NOTICE(LOADER, "AuthID: 0x%llx", authid); - LOG_NOTICE(LOADER, "VendorID: 0x%08x", vendor_id); - LOG_NOTICE(LOADER, "SELF type: 0x%08x", self_type); - LOG_NOTICE(LOADER, "Version: 0x%llx", version); - } + void Show(); }; struct SectionInfo @@ -41,25 +26,9 @@ struct SectionInfo u32 unknown2; u32 encrypted; - void Load(vfsStream& f) - { - offset = Read64(f); - size = Read64(f); - compressed = Read32(f); - unknown1 = Read32(f); - unknown2 = Read32(f); - encrypted = Read32(f); - } + void Load(vfsStream& f); - void Show() - { - LOG_NOTICE(LOADER, "Offset: 0x%llx", offset); - LOG_NOTICE(LOADER, "Size: 0x%llx", size); - LOG_NOTICE(LOADER, "Compressed: 0x%08x", compressed); - LOG_NOTICE(LOADER, "Unknown1: 0x%08x", unknown1); - LOG_NOTICE(LOADER, "Unknown2: 0x%08x", unknown2); - LOG_NOTICE(LOADER, "Encrypted: 0x%08x", encrypted); - } + void Show(); }; struct SCEVersionInfo @@ -69,21 +38,9 @@ struct SCEVersionInfo u32 size; u32 unknown; - void Load(vfsStream& f) - { - subheader_type = Read32(f); - present = Read32(f); - size = Read32(f); - unknown = Read32(f); - } + void Load(vfsStream& f); - void Show() - { - LOG_NOTICE(LOADER, "Sub-header type: 0x%08x", subheader_type); - LOG_NOTICE(LOADER, "Present: 0x%08x", present); - LOG_NOTICE(LOADER, "Size: 0x%08x", size); - LOG_NOTICE(LOADER, "Unknown: 0x%08x", unknown); - } + void Show(); }; struct ControlInfo @@ -133,122 +90,9 @@ struct ControlInfo } npdrm; }; - void Load(vfsStream& f) - { - type = Read32(f); - size = Read32(f); - next = Read64(f); + void Load(vfsStream& f); - if (type == 1) - { - control_flags.ctrl_flag1 = Read32(f); - control_flags.unknown1 = Read32(f); - control_flags.unknown2 = Read32(f); - control_flags.unknown3 = Read32(f); - control_flags.unknown4 = Read32(f); - control_flags.unknown5 = Read32(f); - control_flags.unknown6 = Read32(f); - control_flags.unknown7 = Read32(f); - } - else if (type == 2) - { - if (size == 0x30) - { - f.Read(file_digest_30.digest, 20); - file_digest_30.unknown = Read64(f); - } - else if (size == 0x40) - { - f.Read(file_digest_40.digest1, 20); - f.Read(file_digest_40.digest2, 20); - file_digest_40.unknown = Read64(f); - } - } - else if (type == 3) - { - npdrm.magic = Read32(f); - npdrm.unknown1 = Read32(f); - npdrm.license = Read32(f); - npdrm.type = Read32(f); - f.Read(npdrm.content_id, 48); - f.Read(npdrm.digest, 16); - f.Read(npdrm.invdigest, 16); - f.Read(npdrm.xordigest, 16); - npdrm.unknown2 = Read64(f); - npdrm.unknown3 = Read64(f); - } - } - - void Show() - { - LOG_NOTICE(LOADER, "Type: 0x%08x", type); - LOG_NOTICE(LOADER, "Size: 0x%08x", size); - LOG_NOTICE(LOADER, "Next: 0x%llx", next); - - if (type == 1) - { - LOG_NOTICE(LOADER, "Control flag 1: 0x%08x", control_flags.ctrl_flag1); - LOG_NOTICE(LOADER, "Unknown1: 0x%08x", control_flags.unknown1); - LOG_NOTICE(LOADER, "Unknown2: 0x%08x", control_flags.unknown2); - LOG_NOTICE(LOADER, "Unknown3: 0x%08x", control_flags.unknown3); - LOG_NOTICE(LOADER, "Unknown4: 0x%08x", control_flags.unknown4); - LOG_NOTICE(LOADER, "Unknown5: 0x%08x", control_flags.unknown5); - LOG_NOTICE(LOADER, "Unknown6: 0x%08x", control_flags.unknown6); - LOG_NOTICE(LOADER, "Unknown7: 0x%08x", control_flags.unknown7); - } - else if (type == 2) - { - if (size == 0x30) - { - std::string digest_str; - for (int i = 0; i < 20; i++) - digest_str += fmt::Format("%02x", file_digest_30.digest[i]); - - LOG_NOTICE(LOADER, "Digest: %s", digest_str.c_str()); - LOG_NOTICE(LOADER, "Unknown: 0x%llx", file_digest_30.unknown); - } - else if (size == 0x40) - { - std::string digest_str1; - std::string digest_str2; - for (int i = 0; i < 20; i++) - { - digest_str1 += fmt::Format("%02x", file_digest_40.digest1[i]); - digest_str2 += fmt::Format("%02x", file_digest_40.digest2[i]); - } - - LOG_NOTICE(LOADER, "Digest1: %s", digest_str1.c_str()); - LOG_NOTICE(LOADER, "Digest2: %s", digest_str2.c_str()); - LOG_NOTICE(LOADER, "Unknown: 0x%llx", file_digest_40.unknown); - } - } - else if (type == 3) - { - std::string contentid_str; - std::string digest_str; - std::string invdigest_str; - std::string xordigest_str; - for (int i = 0; i < 48; i++) - contentid_str += fmt::Format("%02x", npdrm.content_id[i]); - for (int i = 0; i < 16; i++) - { - digest_str += fmt::Format("%02x", npdrm.digest[i]); - invdigest_str += fmt::Format("%02x", npdrm.invdigest[i]); - xordigest_str += fmt::Format("%02x", npdrm.xordigest[i]); - } - - LOG_NOTICE(LOADER, "Magic: 0x%08x", npdrm.magic); - LOG_NOTICE(LOADER, "Unknown1: 0x%08x", npdrm.unknown1); - LOG_NOTICE(LOADER, "License: 0x%08x", npdrm.license); - LOG_NOTICE(LOADER, "Type: 0x%08x", npdrm.type); - LOG_NOTICE(LOADER, "ContentID: %s", contentid_str.c_str()); - LOG_NOTICE(LOADER, "Digest: %s", digest_str.c_str()); - LOG_NOTICE(LOADER, "Inverse digest: %s", invdigest_str.c_str()); - LOG_NOTICE(LOADER, "XOR digest: %s", xordigest_str.c_str()); - LOG_NOTICE(LOADER, "Unknown2: 0x%llx", npdrm.unknown2); - LOG_NOTICE(LOADER, "Unknown3: 0x%llx", npdrm.unknown3); - } - } + void Show(); }; @@ -259,33 +103,9 @@ struct MetadataInfo u8 iv[0x10]; u8 iv_pad[0x10]; - void Load(u8* in) - { - memcpy(key, in, 0x10); - memcpy(key_pad, in + 0x10, 0x10); - memcpy(iv, in + 0x20, 0x10); - memcpy(iv_pad, in + 0x30, 0x10); - } + void Load(u8* in); - void Show() - { - std::string key_str; - std::string key_pad_str; - std::string iv_str; - std::string iv_pad_str; - for (int i = 0; i < 0x10; i++) - { - key_str += fmt::Format("%02x", key[i]); - key_pad_str += fmt::Format("%02x", key_pad[i]); - iv_str += fmt::Format("%02x", iv[i]); - iv_pad_str += fmt::Format("%02x", iv_pad[i]); - } - - LOG_NOTICE(LOADER, "Key: %s", key_str.c_str()); - LOG_NOTICE(LOADER, "Key pad: %s", key_pad_str.c_str()); - LOG_NOTICE(LOADER, "IV: %s", iv_str.c_str()); - LOG_NOTICE(LOADER, "IV pad: %s", iv_pad_str.c_str()); - } + void Show(); }; struct MetadataHeader @@ -298,36 +118,9 @@ struct MetadataHeader u32 unknown2; u32 unknown3; - void Load(u8* in) - { - memcpy(&signature_input_length, in, 8); - memcpy(&unknown1, in + 8, 4); - memcpy(§ion_count, in + 12, 4); - memcpy(&key_count, in + 16, 4); - memcpy(&opt_header_size, in + 20, 4); - memcpy(&unknown2, in + 24, 4); - memcpy(&unknown3, in + 28, 4); + void Load(u8* in); - // Endian swap. - signature_input_length = swap64(signature_input_length); - unknown1 = swap32(unknown1); - section_count = swap32(section_count); - key_count = swap32(key_count); - opt_header_size = swap32(opt_header_size); - unknown2 = swap32(unknown2); - unknown3 = swap32(unknown3); - } - - void Show() - { - LOG_NOTICE(LOADER, "Signature input length: 0x%llx", signature_input_length); - LOG_NOTICE(LOADER, "Unknown1: 0x%08x", unknown1); - LOG_NOTICE(LOADER, "Section count: 0x%08x", section_count); - LOG_NOTICE(LOADER, "Key count: 0x%08x", key_count); - LOG_NOTICE(LOADER, "Optional header size: 0x%08x", opt_header_size); - LOG_NOTICE(LOADER, "Unknown2: 0x%08x", unknown2); - LOG_NOTICE(LOADER, "Unknown3: 0x%08x", unknown3); - } + void Show(); }; struct MetadataSectionHeader @@ -343,45 +136,9 @@ struct MetadataSectionHeader u32 iv_idx; u32 compressed; - void Load(u8* in) - { - memcpy(&data_offset, in, 8); - memcpy(&data_size, in + 8, 8); - memcpy(&type, in + 16, 4); - memcpy(&program_idx, in + 20, 4); - memcpy(&hashed, in + 24, 4); - memcpy(&sha1_idx, in + 28, 4); - memcpy(&encrypted, in + 32, 4); - memcpy(&key_idx, in + 36, 4); - memcpy(&iv_idx, in + 40, 4); - memcpy(&compressed, in + 44, 4); + void Load(u8* in); - // Endian swap. - data_offset = swap64(data_offset); - data_size = swap64(data_size); - type = swap32(type); - program_idx = swap32(program_idx); - hashed = swap32(hashed); - sha1_idx = swap32(sha1_idx); - encrypted = swap32(encrypted); - key_idx = swap32(key_idx); - iv_idx = swap32(iv_idx); - compressed = swap32(compressed); - } - - void Show() - { - LOG_NOTICE(LOADER, "Data offset: 0x%llx", data_offset); - LOG_NOTICE(LOADER, "Data size: 0x%llx", data_size); - LOG_NOTICE(LOADER, "Type: 0x%08x", type); - LOG_NOTICE(LOADER, "Program index: 0x%08x", program_idx); - LOG_NOTICE(LOADER, "Hashed: 0x%08x", hashed); - LOG_NOTICE(LOADER, "SHA1 index: 0x%08x", sha1_idx); - LOG_NOTICE(LOADER, "Encrypted: 0x%08x", encrypted); - LOG_NOTICE(LOADER, "Key index: 0x%08x", key_idx); - LOG_NOTICE(LOADER, "IV index: 0x%08x", iv_idx); - LOG_NOTICE(LOADER, "Compressed: 0x%08x", compressed); - } + void Show(); }; struct SectionHash { @@ -389,12 +146,7 @@ struct SectionHash { u8 padding[12]; u8 hmac_key[64]; - void Load(vfsStream& f) - { - f.Read(sha1, 20); - f.Read(padding, 12); - f.Read(hmac_key, 64); - } + void Load(vfsStream& f); }; struct CapabilitiesInfo @@ -409,18 +161,7 @@ struct CapabilitiesInfo u32 unknown4; u32 unknown5; - void Load(vfsStream& f) - { - type = Read32(f); - capabilities_size = Read32(f); - next = Read32(f); - unknown1 = Read32(f); - unknown2 = Read64(f); - unknown3 = Read64(f); - flags = Read64(f); - unknown4 = Read32(f); - unknown5 = Read32(f); - } + void Load(vfsStream& f); }; struct Signature @@ -429,12 +170,7 @@ struct Signature u8 s[21]; u8 padding[6]; - void Load(vfsStream& f) - { - f.Read(r, 21); - f.Read(s, 21); - f.Read(padding, 6); - } + void Load(vfsStream& f); }; struct SelfSection @@ -443,12 +179,7 @@ struct SelfSection u64 size; u64 offset; - void Load(vfsStream& f) - { - *data = Read32(f); - size = Read64(f); - offset = Read64(f); - } + void Load(vfsStream& f); }; class SELFDecrypter diff --git a/rpcs3/Crypto/utils.cpp b/rpcs3/Crypto/utils.cpp index a17013cda9..b395643f20 100644 --- a/rpcs3/Crypto/utils.cpp +++ b/rpcs3/Crypto/utils.cpp @@ -1,4 +1,6 @@ #include "stdafx.h" +#include "aes.h" +#include "sha1.h" #include "utils.h" // Endian swap auxiliary functions. diff --git a/rpcs3/Crypto/utils.h b/rpcs3/Crypto/utils.h index 17ec4e8f5a..4ae1466607 100644 --- a/rpcs3/Crypto/utils.h +++ b/rpcs3/Crypto/utils.h @@ -1,6 +1,4 @@ #pragma once -#include "aes.h" -#include "sha1.h" // Auxiliary functions (endian swap and xor). u16 swap16(u16 i); diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index b9c26d49cd..507e589b51 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "rpcs3/Ini.h" -#include "Emu/SysCalls/ErrorCodes.h" #include "Emu/SysCalls/SysCalls.h" #include "Utilities/Log.h" #include "Emu/Memory/Memory.h" diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index b4700bc5fd..c76ffbb4d9 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -4,7 +4,9 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" +#include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/Modules.h" +#include "Emu/SysCalls/Static.h" #include "Emu/Cell/PPUDecoder.h" #include "Emu/Cell/PPUInterpreter.h" @@ -220,6 +222,11 @@ int FPRdouble::Cmp(PPCdouble a, PPCdouble b) return CR_SO; } +u64 PPUThread::GetStackArg(s32 i) +{ + return Memory.Read64(GPR[1] + 0x70 + 0x8 * (i - 9)); +} + u64 PPUThread::FastCall(u64 addr, u64 rtoc, u64 arg1, u64 arg2, u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7, u64 arg8) { GPR[3] = arg1; diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index 5a5e0bbf58..0e8ff47869 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -842,6 +842,7 @@ public: public: virtual void InitRegs(); virtual u64 GetFreeStackSize() const; + u64 GetStackArg(s32 i); u64 FastCall(u64 addr, u64 rtoc, u64 arg1 = 0, u64 arg2 = 0, u64 arg3 = 0, u64 arg4 = 0, u64 arg5 = 0, u64 arg6 = 0, u64 arg7 = 0, u64 arg8 = 0); u64 FastCall2(u64 addr, u64 rtoc); void FastStop(); @@ -866,3 +867,4 @@ protected: PPUThread& GetCurrentPPUThread(); +#define declCPU PPUThread& CPU = GetCurrentPPUThread diff --git a/rpcs3/Emu/SysCalls/FuncList.cpp b/rpcs3/Emu/SysCalls/FuncList.cpp index c4760519c0..c2fc7cd378 100644 --- a/rpcs3/Emu/SysCalls/FuncList.cpp +++ b/rpcs3/Emu/SysCalls/FuncList.cpp @@ -1,10 +1,6 @@ #include "stdafx.h" -#include "Utilities/Log.h" -#include "Emu/Memory/Memory.h" -#include "Emu/System.h" #include "SysCalls.h" -#define FUNC_LOG_ERROR(x) LOG_ERROR(HLE, x); return 0 std::string SysCalls::GetHLEFuncName(const u32 fid) { switch(fid) diff --git a/rpcs3/Emu/SysCalls/LogBase.cpp b/rpcs3/Emu/SysCalls/LogBase.cpp index 9e11179d4b..6a8f4a6bed 100644 --- a/rpcs3/Emu/SysCalls/LogBase.cpp +++ b/rpcs3/Emu/SysCalls/LogBase.cpp @@ -9,17 +9,24 @@ bool LogBase::CheckLogging() const return Ini.HLELogging.GetValue(); } -void LogBase::LogNotice(const std::string& text) +void LogBase::LogOutput(LogType type, const char* info, const std::string& text) { - LOG_NOTICE(HLE, "%s", text.c_str()); + switch (type) + { + case LogNotice: LOG_NOTICE(HLE, "%s%s%s", GetName().c_str(), info, text.c_str()); break; + case LogSuccess: LOG_SUCCESS(HLE, "%s%s%s", GetName().c_str(), info, text.c_str()); break; + case LogWarning: LOG_WARNING(HLE, "%s%s%s", GetName().c_str(), info, text.c_str()); break; + case LogError: LOG_ERROR(HLE, "%s%s%s", GetName().c_str(), info, text.c_str()); break; + } } -void LogBase::LogWarning(const std::string& text) +void LogBase::LogOutput(LogType type, const u32 id, const char* info, const std::string& text) { - LOG_WARNING(HLE, "%s", text.c_str()); -} - -void LogBase::LogError(const std::string& text) -{ - LOG_ERROR(HLE, "%s", text.c_str()); + switch (type) + { + case LogNotice: LOG_NOTICE(HLE, "%s[%d]%s%s", GetName().c_str(), id, info, text.c_str()); break; + case LogSuccess: LOG_SUCCESS(HLE, "%s[%d]%s%s", GetName().c_str(), id, info, text.c_str()); break; + case LogWarning: LOG_WARNING(HLE, "%s[%d]%s%s", GetName().c_str(), id, info, text.c_str()); break; + case LogError: LOG_ERROR(HLE, "%s[%d]%s%s", GetName().c_str(), id, info, text.c_str()); break; + } } \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/LogBase.h b/rpcs3/Emu/SysCalls/LogBase.h index dac704e974..dc3d280d43 100644 --- a/rpcs3/Emu/SysCalls/LogBase.h +++ b/rpcs3/Emu/SysCalls/LogBase.h @@ -3,11 +3,18 @@ class LogBase { bool m_logging; - bool CheckLogging() const; - void LogNotice(const std::string& text); - void LogWarning(const std::string& text); - void LogError(const std::string& text); + + enum LogType + { + LogNotice, + LogSuccess, + LogWarning, + LogError, + }; + + void LogOutput(LogType type, const char* info, const std::string& text); + void LogOutput(LogType type, const u32 id, const char* info, const std::string& text); public: void SetLogging(bool value) @@ -24,12 +31,12 @@ public: template void Notice(const u32 id, const char* fmt, Targs... args) { - LogNotice(GetName() + fmt::Format("[%d]: ", id) + fmt::Format(fmt, args...)); + LogOutput(LogNotice, id, ": ", fmt::Format(fmt, args...)); } template void Notice(const char* fmt, Targs... args) { - LogNotice(GetName() + ": " + fmt::Format(fmt, args...)); + LogOutput(LogNotice, ": ", fmt::Format(fmt, args...)); } template __forceinline void Log(const char* fmt, Targs... args) @@ -48,33 +55,43 @@ public: } } + template void Success(const u32 id, const char* fmt, Targs... args) + { + LogOutput(LogSuccess, id, ": ", fmt::Format(fmt, args...)); + } + + template void Success(const char* fmt, Targs... args) + { + LogOutput(LogSuccess, ": ", fmt::Format(fmt, args...)); + } + template void Warning(const u32 id, const char* fmt, Targs... args) { - LogWarning(GetName() + fmt::Format("[%d] warning: ", id) + fmt::Format(fmt, args...)); + LogOutput(LogWarning, id, " warning: ", fmt::Format(fmt, args...)); } template void Warning(const char* fmt, Targs... args) { - LogWarning(GetName() + " warning: " + fmt::Format(fmt, args...)); + LogOutput(LogWarning, " warning: ", fmt::Format(fmt, args...)); } template void Error(const u32 id, const char* fmt, Targs... args) { - LogError(GetName() + fmt::Format("[%d] error: ", id) + fmt::Format(fmt, args...)); + LogOutput(LogError, id, " error: ", fmt::Format(fmt, args...)); } template void Error(const char* fmt, Targs... args) { - LogError(GetName() + " error: " + fmt::Format(fmt, args...)); + LogOutput(LogError, " error: ", fmt::Format(fmt, args...)); } template void Todo(const u32 id, const char* fmt, Targs... args) { - LogError(GetName() + fmt::Format("[%d] TODO: ", id) + fmt::Format(fmt, args...)); + LogOutput(LogError, id, " TODO: ", fmt::Format(fmt, args...)); } template void Todo(const char* fmt, Targs... args) { - LogError(GetName() + " TODO: " + fmt::Format(fmt, args...)); + LogOutput(LogError, " TODO: ", fmt::Format(fmt, args...)); } }; \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules.cpp b/rpcs3/Emu/SysCalls/Modules.cpp index 31b2b6b45a..60427fc380 100644 --- a/rpcs3/Emu/SysCalls/Modules.cpp +++ b/rpcs3/Emu/SysCalls/Modules.cpp @@ -2,6 +2,7 @@ #include "Utilities/Log.h" #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" +#include "Emu/SysCalls/Static.h" #include "Crypto/sha1.h" #include #include "ModuleManager.h" @@ -179,7 +180,7 @@ IdManager& Module::GetIdManager() const return Emu.GetIdManager(); } -StaticFuncManager& Module::GetSFuncManager() const +void Module::PushNewFuncSub(SFunc* func) { - return Emu.GetSFuncManager(); + Emu.GetSFuncManager().push_back(func); } \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules.h b/rpcs3/Emu/SysCalls/Modules.h index 18623031ce..722fadaafd 100644 --- a/rpcs3/Emu/SysCalls/Modules.h +++ b/rpcs3/Emu/SysCalls/Modules.h @@ -1,6 +1,6 @@ #pragma once - #include "Emu/SysCalls/SC_FUNC.h" +#include "ErrorCodes.h" #include "LogBase.h" //TODO @@ -17,7 +17,7 @@ struct ModuleFunc ~ModuleFunc() { - safe_delete(func); + delete func; } }; @@ -38,10 +38,12 @@ struct SFunc ~SFunc() { - safe_delete(func); + delete func; } }; +class StaticFuncManager; + class Module : public LogBase { std::string m_name; @@ -51,7 +53,7 @@ class Module : public LogBase void (*m_unload_func)(); IdManager& GetIdManager() const; - StaticFuncManager& GetSFuncManager() const; + void PushNewFuncSub(SFunc* func); public: std::vector m_funcs_list; @@ -155,5 +157,13 @@ __forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], cons op.crc = re(op.crc); sf->ops.push_back(op); } - GetSFuncManager().push_back(sf); + PushNewFuncSub(sf); } + +#define REG_SUB(module, group, name, ...) \ + static const u64 name ## _table[] = {__VA_ARGS__ , 0}; \ + module->AddFuncSub(group, name ## _table, #name, name) + +#define REG_FUNC(module, name) module->AddFunc(getFunctionId(#name), name) + +#define UNIMPLEMENTED_FUNC(module) module->Todo("%s", __FUNCTION__) \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp index 23e30c4efc..4203a77338 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp @@ -3,7 +3,6 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" -#include "Emu/SysCalls/SysCalls.h" #include "cellPamf.h" extern std::mutex g_mutex_avcodec_open2; diff --git a/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp b/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp index fea80fdb1c..ddc1c1bf56 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp @@ -2,7 +2,6 @@ #include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -#include "Emu/SysCalls/SysCalls.h" Module *cellAtrac = nullptr; diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp index 29bb8389e6..f9239b7f81 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp @@ -4,9 +4,9 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" -#include "Emu/SysCalls/SysCalls.h" #include "Utilities/SQueue.h" #include "Emu/Event.h" +#include "Emu/SysCalls/lv2/sys_time.h" #include "Emu/Audio/cellAudio.h" #include "Emu/Audio/AudioManager.h" #include "Emu/Audio/AudioDumper.h" @@ -359,7 +359,7 @@ int cellAudioInit() } } - const u64 stamp1 = get_system_time(); + //const u64 stamp1 = get_system_time(); if (first_mix) { @@ -381,7 +381,7 @@ int cellAudioInit() oal_buffer_offset = 0; } - const u64 stamp2 = get_system_time(); + //const u64 stamp2 = get_system_time(); // send aftermix event (normal audio event) { @@ -409,7 +409,7 @@ int cellAudioInit() Emu.GetEventManager().SendEvent(keys[i], 0x10103000e010e07, 0, 0, 0); } - const u64 stamp3 = get_system_time(); + //const u64 stamp3 = get_system_time(); if (do_dump && !first_mix) { diff --git a/rpcs3/Emu/SysCalls/Modules/cellBgdl.cpp b/rpcs3/Emu/SysCalls/Modules/cellBgdl.cpp index 72879e8d3b..15b7f773e0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellBgdl.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellBgdl.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellBgdl_init(); Module cellBgdl(0x003f, cellBgdl_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp b/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp index ee00c683fa..c2237352bf 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellCamera_init(); Module cellCamera(0x0023, cellCamera_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellCelp8Enc.cpp b/rpcs3/Emu/SysCalls/Modules/cellCelp8Enc.cpp index 70109e224a..83473a902c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellCelp8Enc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellCelp8Enc.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellCelp8Enc_init(); Module cellCelp8Enc(0x0048, cellCelp8Enc_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellCelpEnc.cpp b/rpcs3/Emu/SysCalls/Modules/cellCelpEnc.cpp index 6541f6ae76..03be6b4957 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellCelpEnc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellCelpEnc.cpp @@ -1,8 +1,5 @@ - #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellCelpEnc_init(); Module cellCelpEnc(0xf00a, cellCelpEnc_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp index 13f23a10a3..e1bb563179 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp @@ -4,7 +4,6 @@ #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" #include "Emu/SysCalls/Modules.h" -#include "Emu/SysCalls/SysCalls.h" #include "cellPamf.h" #include "cellDmux.h" diff --git a/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp b/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp index a64a9a914f..eadca3d19f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFiber.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellFiber_init(); Module cellFiber(0x0043, cellFiber_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp index 8629065669..c9b94eea86 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp @@ -4,7 +4,6 @@ #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" #include "Emu/SysCalls/Modules.h" -#include "Emu/SysCalls/SysCalls.h" #include "Emu/FS/vfsFile.h" #include "cellFont.h" #include "stblib/stb_truetype.h" diff --git a/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp b/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp index cf33200cb3..ed1a50092b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp @@ -3,7 +3,6 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" -#include "Emu/SysCalls/SysCalls.h" #include "cellFont.h" //void cellFontFT_init(); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index 085cadb5b0..cec371afba 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -3,9 +3,7 @@ #include "Utilities/rMsgBox.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Emu/SysCalls/SC_FUNC.h" #include "Emu/SysCalls/Modules.h" -#include "Emu/SysCalls/SysCalls.h" #include "Emu/FS/vfsFile.h" #include "Loader/PSF.h" diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index 1642691032..688db567f8 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -3,7 +3,6 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" -#include "Emu/SysCalls/SysCalls.h" #include "Emu/RSX/GCM.h" #include "Emu/SysCalls/lv2/sys_process.h" #include "sysPrxForUser.h" diff --git a/rpcs3/Emu/SysCalls/Modules/cellGem.cpp b/rpcs3/Emu/SysCalls/Modules/cellGem.cpp index 9eba668afa..f70893af79 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGem.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGem.cpp @@ -1,7 +1,6 @@ #include "stdafx.h" #include "Utilities/Log.h" #include "Emu/SysCalls/Modules.h" -#include "Emu/SysCalls/SysCalls.h" #include "cellGem.h" void cellGem_init(); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp index c29d15c44c..9662ba0417 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp @@ -3,9 +3,9 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" -#include "Emu/SysCalls/SysCalls.h" #include "cellGifDec.h" +#include "Emu/SysCalls/lv2/lv2Fs.h" #include "stblib/stb_image.h" #include "stblib/stb_image.c" // (TODO: Should we put this elsewhere?) diff --git a/rpcs3/Emu/SysCalls/Modules/cellHttpUtil.cpp b/rpcs3/Emu/SysCalls/Modules/cellHttpUtil.cpp index 97f94de794..0548c9bf16 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellHttpUtil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellHttpUtil.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellHttpUtil_init(); Module cellHttpUtil(0x0002, cellHttpUtil_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellImejp.cpp b/rpcs3/Emu/SysCalls/Modules/cellImejp.cpp index b3dc1bd5da..3a8ba92062 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellImejp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellImejp.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellImejp_init(); Module cellImejp(0xf023, cellImejp_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp index be776e7456..64eb0696d6 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp @@ -5,6 +5,7 @@ #include "Emu/SysCalls/Modules.h" #include "cellJpgDec.h" #include "stblib/stb_image.h" +#include "Emu/SysCalls/lv2/lv2Fs.h" //void cellJpgDec_init(); //Module cellJpgDec(0x000f, cellJpgDec_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellJpgEnc.cpp b/rpcs3/Emu/SysCalls/Modules/cellJpgEnc.cpp index e8aa461f29..c138f37697 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellJpgEnc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellJpgEnc.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellJpgEnc_init(); Module cellJpgEnc(0x003d, cellJpgEnc_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellKey2char.cpp b/rpcs3/Emu/SysCalls/Modules/cellKey2char.cpp index eef9eb72f7..4b1e6d7a10 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellKey2char.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellKey2char.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellKey2char_init(); Module cellKey2char(0x0021, cellKey2char_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellLv2dbg.cpp b/rpcs3/Emu/SysCalls/Modules/cellLv2dbg.cpp index 01dd518bba..06bd8d77fa 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellLv2dbg.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellLv2dbg.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellLv2dbg_init(); Module cellLv2dbg(0x002e, cellLv2dbg_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellMic.cpp b/rpcs3/Emu/SysCalls/Modules/cellMic.cpp index 23b2a9f61a..a3a665f55e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMic.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMic.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellMic_init(); Module cellMic(0x0022, cellMic_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp index 130efd009c..dc958afdc9 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp @@ -4,6 +4,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" +#include "Emu/SysCalls/lv2/sys_time.h" #include "rpcs3.h" #include "cellSysutil.h" diff --git a/rpcs3/Emu/SysCalls/Modules/cellMusicDecode.cpp b/rpcs3/Emu/SysCalls/Modules/cellMusicDecode.cpp index 14c64aefd0..82acd368b8 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMusicDecode.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMusicDecode.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellMusicDecode_init(); Module cellMusicDecode(0x004f, cellMusicDecode_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellMusicExport.cpp b/rpcs3/Emu/SysCalls/Modules/cellMusicExport.cpp index 7ded73fc72..d8699348c6 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMusicExport.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMusicExport.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellMusicExport_init(); Module cellMusicExport(0xf02c, cellMusicExport_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp b/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp index 25907207e1..f580c41608 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellOvis_init(); Module cellOvis(0x000b, cellOvis_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPhotoDecode.cpp b/rpcs3/Emu/SysCalls/Modules/cellPhotoDecode.cpp index 9281f3c17b..40c68a32b2 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPhotoDecode.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPhotoDecode.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellPhotoDecode_init(); Module cellPhotoDecode(0xf02e, cellPhotoDecode_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPhotoExport.cpp b/rpcs3/Emu/SysCalls/Modules/cellPhotoExport.cpp index 71dd6f5bc9..4dd37501d0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPhotoExport.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPhotoExport.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellPhotoExport_init(); Module cellPhotoExport(0xf029, cellPhotoExport_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPhotoImport.cpp b/rpcs3/Emu/SysCalls/Modules/cellPhotoImport.cpp index c5815b9f5b..3427169d02 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPhotoImport.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPhotoImport.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellPhotoImport_init(); Module cellPhotoImport(0xf02b, cellPhotoImport_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp index d7a03013e7..988cd09c82 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp @@ -5,6 +5,7 @@ #include "Emu/SysCalls/Modules.h" #include "cellPngDec.h" #include "stblib/stb_image.h" +#include "Emu/SysCalls/lv2/lv2Fs.h" #include //void cellPngDec_init(); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngEnc.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngEnc.cpp index 4b59e80a26..e77f231ad1 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngEnc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngEnc.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellPngEnc_init(); Module cellPngEnc(0x0052, cellPngEnc_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPrint.cpp b/rpcs3/Emu/SysCalls/Modules/cellPrint.cpp index 191c53c1d8..1848a277be 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPrint.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPrint.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellPrint_init(); Module cellPrint(0xf02a, cellPrint_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp b/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp index 6cef6bbf08..c7b59517ed 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellRudp_init(); Module cellRudp(0x0057, cellRudp_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSailRec.cpp b/rpcs3/Emu/SysCalls/Modules/cellSailRec.cpp index dce0b36acb..ba88dd083c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSailRec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSailRec.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellSailRec_init(); Module cellSailRec(0xf034, cellSailRec_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellScreenshot.cpp b/rpcs3/Emu/SysCalls/Modules/cellScreenshot.cpp index bcc77d5466..14959e3d0b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellScreenshot.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellScreenshot.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellScreenshot_init(); Module cellScreenshot(0x004e, cellScreenshot_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSearch.cpp b/rpcs3/Emu/SysCalls/Modules/cellSearch.cpp index 8ba73eba86..d56f44ce2a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSearch.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSearch.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellSearch_init(); Module cellSearch(0xf02f, cellSearch_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSheap.cpp b/rpcs3/Emu/SysCalls/Modules/cellSheap.cpp index ea15f3819f..c29c7e6781 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSheap.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSheap.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellSheap_init(); Module cellSheap(0x000c, cellSheap_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSsl.cpp b/rpcs3/Emu/SysCalls/Modules/cellSsl.cpp index c0a30dc9f7..cd6d3b7e45 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSsl.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSsl.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellSsl_init(); Module cellSsl(0x0003, cellSsl_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSubdisplay.cpp b/rpcs3/Emu/SysCalls/Modules/cellSubdisplay.cpp index 467f82d29d..ff0612316b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSubdisplay.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSubdisplay.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellSubdisplay_init(); Module cellSubdisplay(0x0034, cellSubdisplay_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index 0f44d19821..be77ae600f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -3,6 +3,8 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" +#include "Emu/SysCalls/lv2/sys_process.h" +#include "Emu/Event.h" #include "cellSync.h" diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp index 1817f3c1b6..1a7017de43 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellSync2_init(); Module cellSync2(0x0055, cellSync2_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellUsbd.cpp b/rpcs3/Emu/SysCalls/Modules/cellUsbd.cpp index fa4323a05e..07759a9cb4 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellUsbd.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellUsbd.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellUsbd_init(); Module cellUsbd(0x001c, cellUsbd_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellUsbpspcm.cpp b/rpcs3/Emu/SysCalls/Modules/cellUsbpspcm.cpp index 9ce3671f2d..e4bb35bcc1 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellUsbpspcm.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellUsbpspcm.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellUsbpspcm_init(); Module cellUsbpspcm(0x0030, cellUsbpspcm_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellVoice.cpp b/rpcs3/Emu/SysCalls/Modules/cellVoice.cpp index 63dc1763d3..1b568231fd 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVoice.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVoice.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void cellVoice_init(); Module cellVoice(0x0046, cellVoice_init); diff --git a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp index ad594ad883..a2ac4e5beb 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVpost.cpp @@ -127,16 +127,16 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_treserved1 = 0; picInfo->reserved2 = 0; - u64 stamp0 = get_system_time(); + //u64 stamp0 = get_system_time(); std::unique_ptr pA(new u8[w*h]); memset(pA.get(), (const u8)ctrlParam->outAlpha, w*h); - u64 stamp1 = get_system_time(); + //u64 stamp1 = get_system_time(); SwsContext* sws = sws_getContext(w, h, AV_PIX_FMT_YUVA420P, ow, oh, AV_PIX_FMT_RGBA, SWS_BILINEAR, NULL, NULL, NULL); - u64 stamp2 = get_system_time(); + //u64 stamp2 = get_system_time(); u8* in_data[4] = { Memory.GetMemFromAddr(inPicBuff_addr), Memory.GetMemFromAddr(inPicBuff_addr + w*h), Memory.GetMemFromAddr(inPicBuff_addr + w*h + w*h / 4), pA.get() }; int in_line[4] = { w, w/2, w/2, w }; @@ -145,7 +145,7 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t config) if (port.m_is_audio_port_started) { - u64 stamp0 = get_system_time(); + //u64 stamp0 = get_system_time(); memset(mixdata, 0, sizeof(mixdata)); if (surMixerCb) mixerCb->ExecAsCallback(surMixerCb, true, surMixerCbArg, mixcount, 256); - u64 stamp1 = get_system_time(); + //u64 stamp1 = get_system_time(); { std::lock_guard lock(mixer_mutex); @@ -435,7 +435,7 @@ int cellSurMixerCreate(const mem_ptr_t config) } } - u64 stamp2 = get_system_time(); + //u64 stamp2 = get_system_time(); auto buf = (be_t*)&Memory[m_config.m_buffer + (128 * 1024 * SUR_PORT) + (mixcount % port.block) * port.channel * 256 * sizeof(float)]; @@ -445,7 +445,7 @@ int cellSurMixerCreate(const mem_ptr_t config) buf[i] = mixdata[i]; } - u64 stamp3 = get_system_time(); + //u64 stamp3 = get_system_time(); //ConLog.Write("Libmixer perf: start=%lld (cb=%lld, ssp=%lld, finalize=%lld)", stamp0 - m_config.start_time, stamp1 - stamp0, stamp2 - stamp1, stamp3 - stamp2); } diff --git a/rpcs3/Emu/SysCalls/Modules/libsnd3.cpp b/rpcs3/Emu/SysCalls/Modules/libsnd3.cpp index 4e1c84d384..d386b5e709 100644 --- a/rpcs3/Emu/SysCalls/Modules/libsnd3.cpp +++ b/rpcs3/Emu/SysCalls/Modules/libsnd3.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void libsnd3_init(); Module libsnd3("libsnd3", libsnd3_init); diff --git a/rpcs3/Emu/SysCalls/Modules/libsynth2.cpp b/rpcs3/Emu/SysCalls/Modules/libsynth2.cpp index 340d586e24..5f335b1e58 100644 --- a/rpcs3/Emu/SysCalls/Modules/libsynth2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/libsynth2.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void libsynth2_init(); Module libsynth2("libsynth2", libsynth2_init); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index 253001353c..4e3038fb3c 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -3,7 +3,6 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/SC_FUNC.h" #include "Emu/SysCalls/Modules.h" #include "Emu/FS/vfsDir.h" #include "Crypto/unedat.h" diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp index ba6d779920..3297717004 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpClans.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "Utilities/Log.h" +#include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" #include "Emu/System.h" #include "cellRtc.h" diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp index db17213a60..8b6dbc76a7 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "Utilities/Log.h" +#include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" #include "cellRtc.h" #include "sceNpCommerce2.h" diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp index 51c092b9da..3185e257e0 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp @@ -5,7 +5,6 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/SC_FUNC.h" #include "Emu/SysCalls/Modules.h" #include "Emu/FS/vfsDir.h" diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp index dccdecf547..d0f20a9864 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTus.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "Utilities/Log.h" +#include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" #include "cellRtc.h" #include "sceNp.h" diff --git a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp index d09df13b83..2c06cbc7f1 100644 --- a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp @@ -3,11 +3,18 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/SC_FUNC.h" #include "Emu/SysCalls/Modules.h" #include "Emu/FS/vfsFile.h" #include "Emu/FS/vfsStreamMemory.h" #include "Emu/SysCalls/lv2/sys_spu.h" +#include "Emu/SysCalls/lv2/sys_lwmutex.h" +#include "Emu/SysCalls/lv2/sys_spinlock.h" +#include "Emu/SysCalls/lv2/sys_prx.h" +#include "Emu/SysCalls/lv2/sys_ppu_thread.h" +#include "Emu/SysCalls/lv2/sys_process.h" +#include "Emu/SysCalls/lv2/sys_time.h" +#include "Emu/SysCalls/lv2/sys_mmapper.h" +#include "Emu/SysCalls/lv2/sys_lwcond.h" #include "Loader/ELF.h" #include "Emu/Cell/RawSPUThread.h" #include "sysPrxForUser.h" diff --git a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp index 494354f181..87b8fe99b8 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp @@ -4,9 +4,10 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/SC_FUNC.h" #include "Emu/SysCalls/Modules.h" +#include "Emu/SysCalls/lv2/lv2Fs.h" + Module *sys_fs = nullptr; bool sdata_check(u32 version, u32 flags, u64 filesizeInput, u64 filesizeTmp) diff --git a/rpcs3/Emu/SysCalls/Modules/sys_http.cpp b/rpcs3/Emu/SysCalls/Modules/sys_http.cpp index e28671989a..b96bbebafa 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_http.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_http.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #if 0 -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" void sys_http_init(); Module sys_http(0x0001, sys_http_init); diff --git a/rpcs3/Emu/SysCalls/Modules/sys_io.cpp b/rpcs3/Emu/SysCalls/Modules/sys_io.cpp index 60cd11c39b..37fc397e85 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_io.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_io.cpp @@ -3,7 +3,6 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/SC_FUNC.h" #include "Emu/SysCalls/Modules.h" //void sys_io_init(); diff --git a/rpcs3/Emu/SysCalls/Modules/sys_net.cpp b/rpcs3/Emu/SysCalls/Modules/sys_net.cpp index 7885312aae..9923a619cd 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_net.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_net.cpp @@ -3,7 +3,6 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/SC_FUNC.h" #include "Emu/SysCalls/Modules.h" #include "sys_net.h" diff --git a/rpcs3/Emu/SysCalls/SC_FUNC.h b/rpcs3/Emu/SysCalls/SC_FUNC.h index 6b9fde794a..413f1a6d7a 100644 --- a/rpcs3/Emu/SysCalls/SC_FUNC.h +++ b/rpcs3/Emu/SysCalls/SC_FUNC.h @@ -1,10 +1,8 @@ #pragma once -#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/SysCalls.h" -#define RESULT(x) SC_ARGS_1 = (x) +#define RESULT(x) CPU.GPR[3] = (x) class func_caller { @@ -25,7 +23,8 @@ struct get_arg // not fp, not ptr, 1..8 template struct get_arg // ptr, 1..8 { - static __forceinline T func(PPUThread& CPU) { return CPU.GPR[i + 2] ? (T)&Memory[CPU.GPR[i + 2]] : nullptr; } + static_assert(i == 0, "Invalid function argument type: pointer"); + static __forceinline T func(PPUThread& CPU) { return nullptr; } }; template @@ -37,13 +36,14 @@ struct get_arg // fp, 1..12 template struct get_arg // not fp, not ptr, 9..12 { - static __forceinline T func(PPUThread& CPU) { u64 res = Memory.Read64(CPU.GPR[1] + 0x70 + 0x8 * (i - 9)); return (T&)res; } + static __forceinline T func(PPUThread& CPU) { u64 res = CPU.GetStackArg(i); return (T&)res; } }; template struct get_arg // ptr, 9..12 { - static __forceinline T func(PPUThread& CPU) { u64 addr = Memory.Read64(CPU.GPR[1] + 0x70 + 0x8 * (i - 9)); return addr ? (T)&Memory[addr] : nullptr; } + static_assert(i == 0, "Invalid function argument type: pointer"); + static __forceinline T func(PPUThread& CPU) { return nullptr; } }; #define ARG(n) get_arg<((n) > 8), std::is_floating_point::value, std::is_pointer::value, T##n, n>::func(CPU) diff --git a/rpcs3/Emu/SysCalls/Static.cpp b/rpcs3/Emu/SysCalls/Static.cpp index 81d6e52802..e1d206f769 100644 --- a/rpcs3/Emu/SysCalls/Static.cpp +++ b/rpcs3/Emu/SysCalls/Static.cpp @@ -4,7 +4,6 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/SC_FUNC.h" #include "Emu/SysCalls/Modules.h" #include "Static.h" diff --git a/rpcs3/Emu/SysCalls/SysCalls.cpp b/rpcs3/Emu/SysCalls/SysCalls.cpp index c00e6b63f3..ef8a18b00b 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.cpp +++ b/rpcs3/Emu/SysCalls/SysCalls.cpp @@ -5,9 +5,34 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/Modules.h" +#include "Emu/SysCalls/SC_FUNC.h" #include "ModuleManager.h" +#include "lv2/lv2Fs.h" +#include "lv2/sys_cond.h" +#include "lv2/sys_event.h" +#include "lv2/sys_event_flag.h" +#include "lv2/sys_interrupt.h" +#include "lv2/sys_lwcond.h" +#include "lv2/sys_lwmutex.h" +#include "lv2/sys_memory.h" +#include "lv2/sys_mmapper.h" +#include "lv2/sys_ppu_thread.h" +#include "lv2/sys_process.h" +#include "lv2/sys_prx.h" +#include "lv2/sys_rsx.h" +#include "lv2/sys_rwlock.h" +#include "lv2/sys_semaphore.h" +#include "lv2/sys_spinlock.h" +#include "lv2/sys_spu.h" +#include "lv2/sys_time.h" +#include "lv2/sys_timer.h" +#include "lv2/sys_trace.h" +#include "lv2/sys_tty.h" +#include "lv2/sys_vm.h" + +#include "SysCalls.h" + namespace detail{ template<> bool CheckId(u32 id, ID*& _id,const std::string &name) { @@ -20,6 +45,8 @@ static func_caller *null_func = bind_func(default_syscall); static const int kSyscallTableLength = 1024; +extern int cellGcmCallback(u32 context_addr, u32 count); + // UNS = Unused // ROOT = Root // DBG = Debug diff --git a/rpcs3/Emu/SysCalls/SysCalls.h b/rpcs3/Emu/SysCalls/SysCalls.h index 193d364c53..76d6e80214 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.h +++ b/rpcs3/Emu/SysCalls/SysCalls.h @@ -1,39 +1,9 @@ #pragma once #include "ErrorCodes.h" -#include "Static.h" - -#include "Emu/Memory/Memory.h" - -// Most of the headers below rely on Memory.h -#include "lv2/lv2Fs.h" -#include "lv2/sys_cond.h" -#include "lv2/sys_event.h" -#include "lv2/sys_event_flag.h" -#include "lv2/sys_interrupt.h" -#include "lv2/sys_lwcond.h" -#include "lv2/sys_lwmutex.h" -#include "lv2/sys_memory.h" -#include "lv2/sys_mmapper.h" -#include "lv2/sys_ppu_thread.h" -#include "lv2/sys_process.h" -#include "lv2/sys_prx.h" -#include "lv2/sys_rsx.h" -#include "lv2/sys_rwlock.h" -#include "lv2/sys_semaphore.h" -#include "lv2/sys_spinlock.h" -#include "lv2/sys_spu.h" -#include "lv2/sys_time.h" -#include "lv2/sys_timer.h" -#include "lv2/sys_trace.h" -#include "lv2/sys_tty.h" -#include "lv2/sys_vm.h" - #include "LogBase.h" //#define SYSCALLS_DEBUG -#define declCPU PPUThread& CPU = GetCurrentPPUThread - class SysCallBase; namespace detail{ @@ -84,42 +54,6 @@ public: } }; -//cellGcm (used as lv2 syscall #1023) -extern int cellGcmCallback(u32 context_addr, u32 count); - - -#define UNIMPLEMENTED_FUNC(module) module->Todo("%s", __FUNCTION__) - -#define SC_ARG_0 CPU.GPR[3] -#define SC_ARG_1 CPU.GPR[4] -#define SC_ARG_2 CPU.GPR[5] -#define SC_ARG_3 CPU.GPR[6] -#define SC_ARG_4 CPU.GPR[7] -#define SC_ARG_5 CPU.GPR[8] -#define SC_ARG_6 CPU.GPR[9] -#define SC_ARG_7 CPU.GPR[10] -/* // these definitions are wrong: -#define SC_ARG_8 CPU.GPR[11] -#define SC_ARG_9 CPU.GPR[12] -#define SC_ARG_10 CPU.GPR[13] -#define SC_ARG_11 CPU.GPR[14] -*/ - -#define SC_ARGS_1 SC_ARG_0 -#define SC_ARGS_2 SC_ARGS_1,SC_ARG_1 -#define SC_ARGS_3 SC_ARGS_2,SC_ARG_2 -#define SC_ARGS_4 SC_ARGS_3,SC_ARG_3 -#define SC_ARGS_5 SC_ARGS_4,SC_ARG_4 -#define SC_ARGS_6 SC_ARGS_5,SC_ARG_5 -#define SC_ARGS_7 SC_ARGS_6,SC_ARG_6 -#define SC_ARGS_8 SC_ARGS_7,SC_ARG_7 -/* -#define SC_ARGS_9 SC_ARGS_8,SC_ARG_8 -#define SC_ARGS_10 SC_ARGS_9,SC_ARG_9 -#define SC_ARGS_11 SC_ARGS_10,SC_ARG_10 -#define SC_ARGS_12 SC_ARGS_11,SC_ARG_11 -*/ - extern bool dump_enable; class SysCalls @@ -128,9 +62,3 @@ public: static void DoSyscall(u32 code); static std::string GetHLEFuncName(const u32 fid); }; - -#define REG_SUB(module, group, name, ...) \ - static const u64 name ## _table[] = {__VA_ARGS__ , 0}; \ - module->AddFuncSub(group, name ## _table, #name, name) - -#define REG_FUNC(module, name) module->AddFunc(getFunctionId(#name), name) diff --git a/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp b/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp index 76ab51955f..15f1ee826d 100644 --- a/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp +++ b/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp @@ -1,15 +1,12 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/SC_FUNC.h" +//#include "Emu/SysCalls/SysCalls.h" + #include "Emu/SysCalls/Modules.h" #include "Emu/FS/vfsFile.h" #include "Emu/FS/vfsDir.h" - #include "lv2Fs.h" -#include "Emu/SysCalls/SysCalls.h" extern Module *sys_fs; @@ -112,7 +109,7 @@ s32 cellFsOpen(u32 path_addr, s32 flags, mem32_t fd, mem32_t arg, u64 size) } fd = sys_fs->GetNewId(stream, TYPE_FS_FILE); - LOG_NOTICE(HLE, "\"%s\" opened: fd = %d", path.c_str(), fd.GetValue()); + sys_fs->Notice("\"%s\" opened: fd = %d", path.c_str(), fd.GetValue()); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp b/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp index e169fcc740..8a99ac7f25 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp @@ -1,10 +1,9 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Emu/Cell/PPUThread.h" - #include "Emu/SysCalls/SysCalls.h" + +#include "Emu/Cell/PPUThread.h" #include "sys_cond.h" SysCallBase sys_cond("sys_cond"); @@ -74,13 +73,13 @@ s32 sys_cond_signal(u32 cond_id) if (u32 target = (mutex->protocol == SYS_SYNC_PRIORITY ? cond->m_queue.pop_prio() : cond->m_queue.pop())) { - cond->signal_stamp = get_system_time(); + //cond->signal_stamp = get_system_time(); cond->signal.lock(target); Emu.GetCPU().NotifyThread(target); if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_cond_signal(id=%d) aborted", cond_id); + sys_cond.Warning("sys_cond_signal(id=%d) aborted", cond_id); } } @@ -102,13 +101,13 @@ s32 sys_cond_signal_all(u32 cond_id) while (u32 target = (mutex->protocol == SYS_SYNC_PRIORITY ? cond->m_queue.pop_prio() : cond->m_queue.pop())) { cond->signaler = GetCurrentCPUThread()->GetId(); - cond->signal_stamp = get_system_time(); + //cond->signal_stamp = get_system_time(); cond->signal.lock(target); Emu.GetCPU().NotifyThread(target); if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_cond_signal_all(id=%d) aborted", cond_id); + sys_cond.Warning("sys_cond_signal_all(id=%d) aborted", cond_id); break; } } @@ -141,14 +140,14 @@ s32 sys_cond_signal_to(u32 cond_id, u32 thread_id) u32 target = thread_id; { - cond->signal_stamp = get_system_time(); + //cond->signal_stamp = get_system_time(); cond->signal.lock(target); Emu.GetCPU().NotifyThread(target); } if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_cond_signal_to(id=%d, to=%d) aborted", cond_id, thread_id); + sys_cond.Warning("sys_cond_signal_to(id=%d, to=%d) aborted", cond_id, thread_id); } return CELL_OK; @@ -189,7 +188,7 @@ s32 sys_cond_wait(u32 cond_id, u64 timeout) { if (cond->signal.unlock(tid, tid) == SMR_OK) { - const u64 stamp2 = get_system_time(); + //const u64 stamp2 = get_system_time(); if (SMutexResult res = mutex->m_mutex.trylock(tid)) { if (res != SMR_FAILED) @@ -231,6 +230,6 @@ s32 sys_cond_wait(u32 cond_id, u64 timeout) } abort: - LOG_WARNING(HLE, "sys_cond_wait(id=%d) aborted", cond_id); + sys_cond.Warning("sys_cond_wait(id=%d) aborted", cond_id); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event.cpp b/rpcs3/Emu/SysCalls/lv2/sys_event.cpp index b4d5dd2500..953538decd 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_event.cpp @@ -1,9 +1,11 @@ #include "stdafx.h" +#include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Emu/Cell/PPUThread.h" #include "Emu/SysCalls/SysCalls.h" +#include "Emu/Cell/PPUThread.h" #include "Emu/Event.h" +#include "sys_process.h" #include "sys_event.h" SysCallBase sys_event("sys_event"); @@ -235,7 +237,7 @@ s32 sys_event_port_create(mem32_t eport_id, int port_type, u64 name) EventPort* eport = new EventPort(); u32 id = sys_event.GetNewId(eport, TYPE_EVENT_PORT); - eport->name = name ? name : ((u64)sys_process_getpid() << 32) | (u64)id; + eport->name = name ? name : ((u64)process_getpid() << 32) | (u64)id; eport_id = id; sys_event.Warning("*** sys_event_port created: id = %d", id); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp b/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp index ef7bd9ff64..2e5a0e479f 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp @@ -1,11 +1,10 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Emu/Cell/PPUThread.h" - #include "Emu/SysCalls/SysCalls.h" +#include "Emu/Cell/PPUThread.h" +#include "sys_lwmutex.h" #include "sys_event_flag.h" SysCallBase sys_event_flag("sys_event_flag"); @@ -215,7 +214,7 @@ s32 sys_event_flag_wait(u32 eflag_id, u64 bitptn, u32 mode, mem64_t result, u64 } if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_event_flag_wait(id=%d) aborted", eflag_id); + sys_event_flag.Warning("sys_event_flag_wait(id=%d) aborted", eflag_id); return CELL_OK; } } @@ -334,7 +333,7 @@ s32 sys_event_flag_cancel(u32 eflag_id, mem32_t num) if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_event_flag_cancel(id=%d) aborted", eflag_id); + sys_event_flag.Warning("sys_event_flag_cancel(id=%d) aborted", eflag_id); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_interrupt.cpp b/rpcs3/Emu/SysCalls/lv2/sys_interrupt.cpp index 9588d06526..5ab4e2caac 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_interrupt.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_interrupt.cpp @@ -1,18 +1,17 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" +#include "Emu/SysCalls/SysCalls.h" + #include "Emu/Cell/PPUThread.h" #include "Emu/Cell/RawSPUThread.h" -#include "Emu/SysCalls/Modules.h" -#include "Emu/SysCalls/SysCalls.h" #include "sys_interrupt.h" -static SysCallBase sc_int("sys_interrupt"); +static SysCallBase sys_interrupt("sys_interrupt"); s32 sys_interrupt_tag_destroy(u32 intrtag) { - sc_int.Warning("sys_interrupt_tag_destroy(intrtag=%d)", intrtag); + sys_interrupt.Warning("sys_interrupt_tag_destroy(intrtag=%d)", intrtag); u32 id = intrtag & 0xff; u32 class_id = intrtag >> 8; @@ -39,7 +38,7 @@ s32 sys_interrupt_tag_destroy(u32 intrtag) s32 sys_interrupt_thread_establish(mem32_t ih, u32 intrtag, u64 intrthread, u64 arg) { - sc_int.Warning("sys_interrupt_thread_establish(ih_addr=0x%x, intrtag=%d, intrthread=%lld, arg=0x%llx)", ih.GetAddr(), intrtag, intrthread, arg); + sys_interrupt.Warning("sys_interrupt_thread_establish(ih_addr=0x%x, intrtag=%d, intrthread=%lld, arg=0x%llx)", ih.GetAddr(), intrtag, intrthread, arg); u32 id = intrtag & 0xff; u32 class_id = intrtag >> 8; @@ -78,7 +77,7 @@ s32 sys_interrupt_thread_establish(mem32_t ih, u32 intrtag, u64 intrthread, u64 s32 sys_interrupt_thread_disestablish(u32 ih) { - sc_int.Todo("sys_interrupt_thread_disestablish(ih=%d)", ih); + sys_interrupt.Todo("sys_interrupt_thread_disestablish(ih=%d)", ih); CPUThread* it = Emu.GetCPU().GetThread(ih); if (!it) @@ -98,7 +97,7 @@ s32 sys_interrupt_thread_disestablish(u32 ih) void sys_interrupt_thread_eoi() { - sc_int.Log("sys_interrupt_thread_eoi()"); + sys_interrupt.Log("sys_interrupt_thread_eoi()"); GetCurrentPPUThread().FastStop(); return; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp b/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp index 57943453bb..4e368f9ed7 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp @@ -1,9 +1,9 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Emu/Cell/PPUThread.h" #include "Emu/SysCalls/SysCalls.h" + +#include "Emu/Cell/PPUThread.h" #include "sys_lwmutex.h" #include "sys_lwcond.h" @@ -63,7 +63,7 @@ s32 sys_lwcond_signal(mem_ptr_t lwcond) if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_lwcond_signal(id=%d) aborted", (u32)lwcond->lwcond_queue); + sys_lwcond.Warning("sys_lwcond_signal(id=%d) aborted", (u32)lwcond->lwcond_queue); return CELL_OK; } } @@ -89,7 +89,7 @@ s32 sys_lwcond_signal_all(mem_ptr_t lwcond) if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_lwcond_signal_all(id=%d) aborted", (u32)lwcond->lwcond_queue); + sys_lwcond.Warning("sys_lwcond_signal_all(id=%d) aborted", (u32)lwcond->lwcond_queue); return CELL_OK; } } @@ -123,7 +123,7 @@ s32 sys_lwcond_signal_to(mem_ptr_t lwcond, u32 ppu_thread_id) if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_lwcond_signal_to(id=%d, to=%d) aborted", (u32)lwcond->lwcond_queue, ppu_thread_id); + sys_lwcond.Warning("sys_lwcond_signal_to(id=%d, to=%d) aborted", (u32)lwcond->lwcond_queue, ppu_thread_id); return CELL_OK; } } @@ -213,6 +213,6 @@ s32 sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) } abort: - LOG_WARNING(HLE, "sys_lwcond_wait(id=%d) aborted", (u32)lwcond->lwcond_queue); + sys_lwcond.Warning("sys_lwcond_wait(id=%d) aborted", (u32)lwcond->lwcond_queue); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp b/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp index 267b68a0d0..61fb1141c5 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp @@ -1,32 +1,34 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Emu/Cell/PPUThread.h" #include "Emu/SysCalls/SysCalls.h" + +#include "Emu/Cell/PPUThread.h" #include "sys_lwmutex.h" -SysCallBase sc_lwmutex("sys_lwmutex"); +SysCallBase sys_lwmutex("sys_lwmutex"); + +// TODO: move SleepQueue somewhere s32 sys_lwmutex_create(mem_ptr_t lwmutex, mem_ptr_t attr) { - sc_lwmutex.Log("sys_lwmutex_create(lwmutex_addr=0x%x, lwmutex_attr_addr=0x%x)", + sys_lwmutex.Log("sys_lwmutex_create(lwmutex_addr=0x%x, lwmutex_attr_addr=0x%x)", lwmutex.GetAddr(), attr.GetAddr()); switch (attr->attr_recursive.ToBE()) { case se32(SYS_SYNC_RECURSIVE): break; case se32(SYS_SYNC_NOT_RECURSIVE): break; - default: sc_lwmutex.Error("Unknown recursive attribute(0x%x)", (u32)attr->attr_recursive); return CELL_EINVAL; + default: sys_lwmutex.Error("Unknown recursive attribute(0x%x)", (u32)attr->attr_recursive); return CELL_EINVAL; } switch (attr->attr_protocol.ToBE()) { case se32(SYS_SYNC_PRIORITY): break; case se32(SYS_SYNC_RETRY): break; - case se32(SYS_SYNC_PRIORITY_INHERIT): sc_lwmutex.Error("Invalid SYS_SYNC_PRIORITY_INHERIT protocol attr"); return CELL_EINVAL; + case se32(SYS_SYNC_PRIORITY_INHERIT): sys_lwmutex.Error("Invalid SYS_SYNC_PRIORITY_INHERIT protocol attr"); return CELL_EINVAL; case se32(SYS_SYNC_FIFO): break; - default: sc_lwmutex.Error("Unknown protocol attribute(0x%x)", (u32)attr->attr_protocol); return CELL_EINVAL; + default: sys_lwmutex.Error("Unknown protocol attribute(0x%x)", (u32)attr->attr_protocol); return CELL_EINVAL; } lwmutex->attribute = attr->attr_protocol | attr->attr_recursive; @@ -36,10 +38,10 @@ s32 sys_lwmutex_create(mem_ptr_t lwmutex, mem_ptr_tpad = 0; lwmutex->recursive_count = 0; - u32 sq_id = sc_lwmutex.GetNewId(new SleepQueue(attr->name_u64), TYPE_LWMUTEX); + u32 sq_id = sys_lwmutex.GetNewId(new SleepQueue(attr->name_u64), TYPE_LWMUTEX); lwmutex->sleep_queue = sq_id; - sc_lwmutex.Warning("*** lwmutex created [%s] (attribute=0x%x): sq_id = %d", + sys_lwmutex.Warning("*** lwmutex created [%s] (attribute=0x%x): sq_id = %d", std::string(attr->name, 8).c_str(), (u32) lwmutex->attribute, sq_id); return CELL_OK; @@ -47,7 +49,7 @@ s32 sys_lwmutex_create(mem_ptr_t lwmutex, mem_ptr_t lwmutex) { - sc_lwmutex.Warning("sys_lwmutex_destroy(lwmutex_addr=0x%x)", lwmutex.GetAddr()); + sys_lwmutex.Warning("sys_lwmutex_destroy(lwmutex_addr=0x%x)", lwmutex.GetAddr()); u32 sq_id = lwmutex->sleep_queue; if (!Emu.GetIdManager().CheckID(sq_id)) return CELL_ESRCH; @@ -66,7 +68,7 @@ s32 sys_lwmutex_destroy(mem_ptr_t lwmutex) s32 sys_lwmutex_lock(mem_ptr_t lwmutex, u64 timeout) { - sc_lwmutex.Log("sys_lwmutex_lock(lwmutex_addr=0x%x, timeout=%lld)", lwmutex.GetAddr(), timeout); + sys_lwmutex.Log("sys_lwmutex_lock(lwmutex_addr=0x%x, timeout=%lld)", lwmutex.GetAddr(), timeout); //ConLog.Write("*** lock mutex (addr=0x%x, attr=0x%x, Nrec=%d, owner=%d, waiter=%d)", //lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, lwmutex->vars.parts.owner.GetOwner(), (u32)lwmutex->waiter); @@ -76,14 +78,14 @@ s32 sys_lwmutex_lock(mem_ptr_t lwmutex, u64 timeout) s32 sys_lwmutex_trylock(mem_ptr_t lwmutex) { - sc_lwmutex.Log("sys_lwmutex_trylock(lwmutex_addr=0x%x)", lwmutex.GetAddr()); + sys_lwmutex.Log("sys_lwmutex_trylock(lwmutex_addr=0x%x)", lwmutex.GetAddr()); return lwmutex->trylock(be_t::MakeFromLE(GetCurrentPPUThread().GetId())); } s32 sys_lwmutex_unlock(mem_ptr_t lwmutex) { - sc_lwmutex.Log("sys_lwmutex_unlock(lwmutex_addr=0x%x)", lwmutex.GetAddr()); + sys_lwmutex.Log("sys_lwmutex_unlock(lwmutex_addr=0x%x)", lwmutex.GetAddr()); //ConLog.Write("*** unlocking mutex (addr=0x%x, attr=0x%x, Nrec=%d, owner=%d, waiter=%d)", //lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, (u32)lwmutex->vars.parts.owner.GetOwner(), (u32)lwmutex->waiter); @@ -158,7 +160,7 @@ u32 SleepQueue::pop_prio() // SYS_SYNC_PRIORITY u32 SleepQueue::pop_prio_inherit() // (TODO) { - LOG_ERROR(HLE, "TODO: SleepQueue::pop_prio_inherit()"); + sys_lwmutex.Error("TODO: SleepQueue::pop_prio_inherit()"); Emu.Pause(); return 0; } @@ -278,7 +280,7 @@ int sys_lwmutex_t::unlock(be_t tid) { if (!recursive_count || (recursive_count.ToBE() != se32(1) && (attribute.ToBE() & se32(SYS_SYNC_NOT_RECURSIVE)))) { - sc_lwmutex.Error("sys_lwmutex_t::unlock(%d): wrong recursive value fixed (%d)", (u32)sleep_queue, (u32)recursive_count); + sys_lwmutex.Error("sys_lwmutex_t::unlock(%d): wrong recursive value fixed (%d)", (u32)sleep_queue, (u32)recursive_count); recursive_count = 1; } recursive_count -= 1; @@ -329,7 +331,7 @@ int sys_lwmutex_t::lock(be_t tid, u64 timeout) case SMR_TIMEOUT: sq->invalidate(tid); return CELL_ETIMEDOUT; case SMR_ABORT: - if (Emu.IsStopped()) LOG_WARNING(HLE, "sys_lwmutex_t::lock(sq=%d) aborted", (u32)sleep_queue); + if (Emu.IsStopped()) sys_lwmutex.Warning("sys_lwmutex_t::lock(sq=%d) aborted", (u32)sleep_queue); default: sq->invalidate(tid); return CELL_EINVAL; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_memory.cpp b/rpcs3/Emu/SysCalls/lv2/sys_memory.cpp index 936b5ff0ac..30035fe135 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_memory.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_memory.cpp @@ -1,16 +1,16 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" + #include "sys_memory.h" #include -SysCallBase sc_mem("memory"); +SysCallBase sys_memory("sys_memory"); s32 sys_memory_allocate(u32 size, u32 flags, u32 alloc_addr_addr) { - sc_mem.Log("sys_memory_allocate(size=0x%x, flags=0x%x)", size, flags); + sys_memory.Log("sys_memory_allocate(size=0x%x, flags=0x%x)", size, flags); // Check page size. u32 addr; @@ -33,7 +33,7 @@ s32 sys_memory_allocate(u32 size, u32 flags, u32 alloc_addr_addr) return CELL_ENOMEM; // Write back the start address of the allocated area. - sc_mem.Log("Memory allocated! [addr: 0x%x, size: 0x%x]", addr, size); + sys_memory.Log("Memory allocated! [addr: 0x%x, size: 0x%x]", addr, size); Memory.Write32(alloc_addr_addr, addr); return CELL_OK; @@ -41,11 +41,11 @@ s32 sys_memory_allocate(u32 size, u32 flags, u32 alloc_addr_addr) s32 sys_memory_allocate_from_container(u32 size, u32 cid, u32 flags, u32 alloc_addr_addr) { - sc_mem.Log("sys_memory_allocate_from_container(size=0x%x, cid=0x%x, flags=0x%x)", size, cid, flags); + sys_memory.Log("sys_memory_allocate_from_container(size=0x%x, cid=0x%x, flags=0x%x)", size, cid, flags); // Check if this container ID is valid. MemoryContainerInfo* ct; - if(!sc_mem.CheckId(cid, ct)) + if (!sys_memory.CheckId(cid, ct)) return CELL_ESRCH; // Check page size. @@ -70,7 +70,7 @@ s32 sys_memory_allocate_from_container(u32 size, u32 cid, u32 flags, u32 alloc_a ct->size = size; // Write back the start address of the allocated area. - sc_mem.Log("Memory allocated! [addr: 0x%x, size: 0x%x]", ct->addr, ct->size); + sys_memory.Log("Memory allocated! [addr: 0x%x, size: 0x%x]", ct->addr, ct->size); Memory.Write32(alloc_addr_addr, ct->addr); return CELL_OK; @@ -78,7 +78,7 @@ s32 sys_memory_allocate_from_container(u32 size, u32 cid, u32 flags, u32 alloc_a s32 sys_memory_free(u32 start_addr) { - sc_mem.Log("sys_memory_free(start_addr=0x%x)", start_addr); + sys_memory.Log("sys_memory_free(start_addr=0x%x)", start_addr); // Release the allocated memory. if(!Memory.Free(start_addr)) @@ -89,7 +89,7 @@ s32 sys_memory_free(u32 start_addr) s32 sys_memory_get_page_attribute(u32 addr, mem_ptr_t attr) { - sc_mem.Warning("sys_memory_get_page_attribute(addr=0x%x, attr_addr=0x%x)", addr, attr.GetAddr()); + sys_memory.Warning("sys_memory_get_page_attribute(addr=0x%x, attr_addr=0x%x)", addr, attr.GetAddr()); // TODO: Implement per thread page attribute setting. attr->attribute = 0; @@ -102,7 +102,7 @@ s32 sys_memory_get_page_attribute(u32 addr, mem_ptr_t attr) s32 sys_memory_get_user_memory_size(mem_ptr_t mem_info) { - sc_mem.Warning("sys_memory_get_user_memory_size(mem_info_addr=0x%x)", mem_info.GetAddr()); + sys_memory.Warning("sys_memory_get_user_memory_size(mem_info_addr=0x%x)", mem_info.GetAddr()); // Fetch the user memory available. mem_info->total_user_memory = Memory.GetUserMemTotalSize(); @@ -112,7 +112,7 @@ s32 sys_memory_get_user_memory_size(mem_ptr_t mem_info) s32 sys_memory_container_create(mem32_t cid, u32 yield_size) { - sc_mem.Warning("sys_memory_container_create(cid_addr=0x%x, yield_size=0x%x)", cid.GetAddr(), yield_size); + sys_memory.Warning("sys_memory_container_create(cid_addr=0x%x, yield_size=0x%x)", cid.GetAddr(), yield_size); yield_size &= ~0xfffff; //round down to 1 MB granularity u64 addr = Memory.Alloc(yield_size, 0x100000); //1 MB alignment @@ -122,20 +122,20 @@ s32 sys_memory_container_create(mem32_t cid, u32 yield_size) // Wrap the allocated memory in a memory container. MemoryContainerInfo *ct = new MemoryContainerInfo(addr, yield_size); - cid = sc_mem.GetNewId(ct, TYPE_MEM); + cid = sys_memory.GetNewId(ct, TYPE_MEM); - sc_mem.Warning("*** memory_container created(addr=0x%llx): id = %d", addr, cid.GetValue()); + sys_memory.Warning("*** memory_container created(addr=0x%llx): id = %d", addr, cid.GetValue()); return CELL_OK; } s32 sys_memory_container_destroy(u32 cid) { - sc_mem.Warning("sys_memory_container_destroy(cid=%d)", cid); + sys_memory.Warning("sys_memory_container_destroy(cid=%d)", cid); // Check if this container ID is valid. MemoryContainerInfo* ct; - if(!sc_mem.CheckId(cid, ct)) + if (!sys_memory.CheckId(cid, ct)) return CELL_ESRCH; // Release the allocated memory and remove the ID. @@ -147,11 +147,11 @@ s32 sys_memory_container_destroy(u32 cid) s32 sys_memory_container_get_size(mem_ptr_t mem_info, u32 cid) { - sc_mem.Warning("sys_memory_container_get_size(mem_info_addr=0x%x, cid=%d)", mem_info.GetAddr(), cid); + sys_memory.Warning("sys_memory_container_get_size(mem_info_addr=0x%x, cid=%d)", mem_info.GetAddr(), cid); // Check if this container ID is valid. MemoryContainerInfo* ct; - if(!sc_mem.CheckId(cid, ct)) + if (!sys_memory.CheckId(cid, ct)) return CELL_ESRCH; // HACK: Return all memory. diff --git a/rpcs3/Emu/SysCalls/lv2/sys_mmapper.cpp b/rpcs3/Emu/SysCalls/lv2/sys_mmapper.cpp index 170c063fdc..603e17b6a3 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_mmapper.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_mmapper.cpp @@ -1,8 +1,8 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" + #include "sys_memory.h" #include "sys_mmapper.h" #include diff --git a/rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp b/rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp index f07601ae9b..b9e4e57371 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_mutex.cpp @@ -1,26 +1,25 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Emu/Cell/PPUThread.h" #include "Emu/SysCalls/SysCalls.h" -#include "Utilities/SMutex.h" + +#include "Emu/Cell/PPUThread.h" #include "sys_mutex.h" -SysCallBase sys_mtx("sys_mutex"); +SysCallBase sys_mutex("sys_mutex"); Mutex::~Mutex() { if (u32 owner = m_mutex.GetOwner()) { - LOG_NOTICE(HLE, "Mutex(%d) was owned by thread %d (recursive=%d)", id, owner, recursive); + sys_mutex.Notice("Mutex(%d) was owned by thread %d (recursive=%d)", id, owner, recursive); } if (!m_queue.m_mutex.try_lock()) return; for (u32 i = 0; i < m_queue.list.size(); i++) { - if (u32 owner = m_queue.list[i]) LOG_NOTICE(HLE, "Mutex(%d) was waited by thread %d", id, owner); + if (u32 owner = m_queue.list[i]) sys_mutex.Notice("Mutex(%d) was waited by thread %d", id, owner); } m_queue.m_mutex.unlock(); @@ -28,15 +27,15 @@ Mutex::~Mutex() s32 sys_mutex_create(mem32_t mutex_id, mem_ptr_t attr) { - sys_mtx.Log("sys_mutex_create(mutex_id_addr=0x%x, attr_addr=0x%x)", mutex_id.GetAddr(), attr.GetAddr()); + sys_mutex.Log("sys_mutex_create(mutex_id_addr=0x%x, attr_addr=0x%x)", mutex_id.GetAddr(), attr.GetAddr()); switch (attr->protocol.ToBE()) { case se32(SYS_SYNC_FIFO): break; case se32(SYS_SYNC_PRIORITY): break; - case se32(SYS_SYNC_PRIORITY_INHERIT): sys_mtx.Todo("sys_mutex_create(): SYS_SYNC_PRIORITY_INHERIT"); break; - case se32(SYS_SYNC_RETRY): sys_mtx.Error("sys_mutex_create(): SYS_SYNC_RETRY"); return CELL_EINVAL; - default: sys_mtx.Error("Unknown protocol attribute(0x%x)", (u32)attr->protocol); return CELL_EINVAL; + case se32(SYS_SYNC_PRIORITY_INHERIT): sys_mutex.Todo("sys_mutex_create(): SYS_SYNC_PRIORITY_INHERIT"); break; + case se32(SYS_SYNC_RETRY): sys_mutex.Error("sys_mutex_create(): SYS_SYNC_RETRY"); return CELL_EINVAL; + default: sys_mutex.Error("Unknown protocol attribute(0x%x)", (u32)attr->protocol); return CELL_EINVAL; } bool is_recursive; @@ -44,23 +43,23 @@ s32 sys_mutex_create(mem32_t mutex_id, mem_ptr_t attr) { case se32(SYS_SYNC_RECURSIVE): is_recursive = true; break; case se32(SYS_SYNC_NOT_RECURSIVE): is_recursive = false; break; - default: sys_mtx.Error("Unknown recursive attribute(0x%x)", (u32)attr->recursive); return CELL_EINVAL; + default: sys_mutex.Error("Unknown recursive attribute(0x%x)", (u32)attr->recursive); return CELL_EINVAL; } if (attr->pshared.ToBE() != se32(0x200)) { - sys_mtx.Error("Unknown pshared attribute(0x%x)", (u32)attr->pshared); + sys_mutex.Error("Unknown pshared attribute(0x%x)", (u32)attr->pshared); return CELL_EINVAL; } u32 tid = GetCurrentPPUThread().GetId(); Mutex* mutex = new Mutex((u32)attr->protocol, is_recursive, attr->name_u64); - u32 id = sys_mtx.GetNewId(mutex, TYPE_MUTEX); + u32 id = sys_mutex.GetNewId(mutex, TYPE_MUTEX); mutex->m_mutex.lock(tid); mutex->id = id; mutex_id = id; mutex->m_mutex.unlock(tid); - sys_mtx.Warning("*** mutex created [%s] (protocol=0x%x, recursive=%s): id = %d", + sys_mutex.Warning("*** mutex created [%s] (protocol=0x%x, recursive=%s): id = %d", std::string(attr->name, 8).c_str(), (u32) attr->protocol, (is_recursive ? "true" : "false"), mutex_id.GetValue()); @@ -71,7 +70,7 @@ s32 sys_mutex_create(mem32_t mutex_id, mem_ptr_t attr) s32 sys_mutex_destroy(u32 mutex_id) { - sys_mtx.Warning("sys_mutex_destroy(mutex_id=%d)", mutex_id); + sys_mutex.Warning("sys_mutex_destroy(mutex_id=%d)", mutex_id); Mutex* mutex; if (!Emu.GetIdManager().GetIDData(mutex_id, mutex)) @@ -104,7 +103,7 @@ s32 sys_mutex_destroy(u32 mutex_id) s32 sys_mutex_lock(u32 mutex_id, u64 timeout) { - sys_mtx.Log("sys_mutex_lock(mutex_id=%d, timeout=%lld)", mutex_id, timeout); + sys_mutex.Log("sys_mutex_lock(mutex_id=%d, timeout=%lld)", mutex_id, timeout); Mutex* mutex; if (!Emu.GetIdManager().GetIDData(mutex_id, mutex)) @@ -137,7 +136,7 @@ s32 sys_mutex_lock(u32 mutex_id, u64 timeout) } else { - sys_mtx.Error("sys_mutex_lock(%d): deadlock on invalid thread(%d)", mutex_id, owner); + sys_mutex.Error("sys_mutex_lock(%d): deadlock on invalid thread(%d)", mutex_id, owner); } } @@ -165,7 +164,7 @@ s32 sys_mutex_lock(u32 mutex_id, u64 timeout) abort: if (Emu.IsStopped()) { - sys_mtx.Warning("sys_mutex_lock(id=%d) aborted", mutex_id); + sys_mutex.Warning("sys_mutex_lock(id=%d) aborted", mutex_id); return CELL_OK; } return CELL_ESRCH; @@ -173,7 +172,7 @@ abort: s32 sys_mutex_trylock(u32 mutex_id) { - sys_mtx.Log("sys_mutex_trylock(mutex_id=%d)", mutex_id); + sys_mutex.Log("sys_mutex_trylock(mutex_id=%d)", mutex_id); Mutex* mutex; if (!Emu.GetIdManager().GetIDData(mutex_id, mutex)) @@ -206,7 +205,7 @@ s32 sys_mutex_trylock(u32 mutex_id) } else { - sys_mtx.Error("sys_mutex_trylock(%d): deadlock on invalid thread(%d)", mutex_id, owner); + sys_mutex.Error("sys_mutex_trylock(%d): deadlock on invalid thread(%d)", mutex_id, owner); } } @@ -220,7 +219,7 @@ s32 sys_mutex_trylock(u32 mutex_id) s32 sys_mutex_unlock(u32 mutex_id) { - sys_mtx.Log("sys_mutex_unlock(mutex_id=%d)", mutex_id); + sys_mutex.Log("sys_mutex_unlock(mutex_id=%d)", mutex_id); Mutex* mutex; if (!Emu.GetIdManager().GetIDData(mutex_id, mutex)) @@ -235,7 +234,7 @@ s32 sys_mutex_unlock(u32 mutex_id) { if (!mutex->recursive || (mutex->recursive != 1 && !mutex->is_recursive)) { - sys_mtx.Error("sys_mutex_unlock(%d): wrong recursive value fixed (%d)", mutex_id, mutex->recursive); + sys_mutex.Error("sys_mutex_unlock(%d): wrong recursive value fixed (%d)", mutex_id, mutex->recursive); mutex->recursive = 1; } mutex->recursive--; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp index 9a69b5b4b5..7dfba3b29c 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp @@ -1,14 +1,12 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/SC_FUNC.h" -#include "Emu/SysCalls/Modules.h" #include "Emu/SysCalls/SysCalls.h" + +#include "Emu/Cell/PPUThread.h" #include "sys_ppu_thread.h" -extern Module *sysPrxForUser; +static SysCallBase sys_ppu_thread("sys_ppu_thread"); static const u32 PPU_THREAD_ID_INVALID = 0xFFFFFFFFU/*UUUUUUUUUUuuuuuuuuuu~~~~~~~~*/; @@ -19,7 +17,7 @@ void ppu_thread_exit(u64 errorcode) if (thr.owned_mutexes) { - LOG_ERROR(PPU, "Owned mutexes found (%d)", thr.owned_mutexes); + sys_ppu_thread.Error("Owned mutexes found (%d)", thr.owned_mutexes); thr.owned_mutexes = 0; } @@ -29,21 +27,21 @@ void ppu_thread_exit(u64 errorcode) void sys_ppu_thread_exit(u64 errorcode) { - sysPrxForUser->Log("sys_ppu_thread_exit(0x%llx)", errorcode); + sys_ppu_thread.Log("sys_ppu_thread_exit(0x%llx)", errorcode); ppu_thread_exit(errorcode); } void sys_internal_ppu_thread_exit(u64 errorcode) { - sysPrxForUser->Log("sys_internal_ppu_thread_exit(0x%llx)", errorcode); + sys_ppu_thread.Log("sys_internal_ppu_thread_exit(0x%llx)", errorcode); ppu_thread_exit(errorcode); } s32 sys_ppu_thread_yield() { - sysPrxForUser->Log("sys_ppu_thread_yield()"); + sys_ppu_thread.Log("sys_ppu_thread_yield()"); // Note: Or do we actually want to yield? std::this_thread::sleep_for(std::chrono::milliseconds(1)); return CELL_OK; @@ -51,7 +49,7 @@ s32 sys_ppu_thread_yield() s32 sys_ppu_thread_join(u64 thread_id, mem64_t vptr) { - sysPrxForUser->Warning("sys_ppu_thread_join(thread_id=%lld, vptr_addr=0x%x)", thread_id, vptr.GetAddr()); + sys_ppu_thread.Warning("sys_ppu_thread_join(thread_id=%lld, vptr_addr=0x%x)", thread_id, vptr.GetAddr()); CPUThread* thr = Emu.GetCPU().GetThread(thread_id); if(!thr) return CELL_ESRCH; @@ -60,7 +58,7 @@ s32 sys_ppu_thread_join(u64 thread_id, mem64_t vptr) { if (Emu.IsStopped()) { - LOG_WARNING(PPU, "sys_ppu_thread_join(%d) aborted", thread_id); + sys_ppu_thread.Warning("sys_ppu_thread_join(%d) aborted", thread_id); return CELL_OK; } std::this_thread::sleep_for(std::chrono::milliseconds(1)); @@ -72,7 +70,7 @@ s32 sys_ppu_thread_join(u64 thread_id, mem64_t vptr) s32 sys_ppu_thread_detach(u64 thread_id) { - sysPrxForUser->Todo("sys_ppu_thread_detach(thread_id=%lld)", thread_id); + sys_ppu_thread.Todo("sys_ppu_thread_detach(thread_id=%lld)", thread_id); CPUThread* thr = Emu.GetCPU().GetThread(thread_id); if(!thr) return CELL_ESRCH; @@ -86,13 +84,13 @@ s32 sys_ppu_thread_detach(u64 thread_id) void sys_ppu_thread_get_join_state(u32 isjoinable_addr) { - sysPrxForUser->Warning("sys_ppu_thread_get_join_state(isjoinable_addr=0x%x)", isjoinable_addr); + sys_ppu_thread.Warning("sys_ppu_thread_get_join_state(isjoinable_addr=0x%x)", isjoinable_addr); Memory.Write32(isjoinable_addr, GetCurrentPPUThread().IsJoinable()); } s32 sys_ppu_thread_set_priority(u64 thread_id, s32 prio) { - sysPrxForUser->Log("sys_ppu_thread_set_priority(thread_id=%lld, prio=%d)", thread_id, prio); + sys_ppu_thread.Log("sys_ppu_thread_set_priority(thread_id=%lld, prio=%d)", thread_id, prio); CPUThread* thr = Emu.GetCPU().GetThread(thread_id); if(!thr) return CELL_ESRCH; @@ -104,7 +102,7 @@ s32 sys_ppu_thread_set_priority(u64 thread_id, s32 prio) s32 sys_ppu_thread_get_priority(u64 thread_id, u32 prio_addr) { - sysPrxForUser->Log("sys_ppu_thread_get_priority(thread_id=%lld, prio_addr=0x%x)", thread_id, prio_addr); + sys_ppu_thread.Log("sys_ppu_thread_get_priority(thread_id=%lld, prio_addr=0x%x)", thread_id, prio_addr); CPUThread* thr = Emu.GetCPU().GetThread(thread_id); if(!thr) return CELL_ESRCH; @@ -116,7 +114,7 @@ s32 sys_ppu_thread_get_priority(u64 thread_id, u32 prio_addr) s32 sys_ppu_thread_get_stack_information(u32 info_addr) { - sysPrxForUser->Log("sys_ppu_thread_get_stack_information(info_addr=0x%x)", info_addr); + sys_ppu_thread.Log("sys_ppu_thread_get_stack_information(info_addr=0x%x)", info_addr); declCPU(); @@ -128,7 +126,7 @@ s32 sys_ppu_thread_get_stack_information(u32 info_addr) s32 sys_ppu_thread_stop(u64 thread_id) { - sysPrxForUser->Warning("sys_ppu_thread_stop(thread_id=%lld)", thread_id); + sys_ppu_thread.Warning("sys_ppu_thread_stop(thread_id=%lld)", thread_id); CPUThread* thr = Emu.GetCPU().GetThread(thread_id); if(!thr) return CELL_ESRCH; @@ -140,7 +138,7 @@ s32 sys_ppu_thread_stop(u64 thread_id) s32 sys_ppu_thread_restart(u64 thread_id) { - sysPrxForUser->Warning("sys_ppu_thread_restart(thread_id=%lld)", thread_id); + sys_ppu_thread.Warning("sys_ppu_thread_restart(thread_id=%lld)", thread_id); CPUThread* thr = Emu.GetCPU().GetThread(thread_id); if(!thr) return CELL_ESRCH; @@ -156,7 +154,7 @@ s32 sys_ppu_thread_create(mem64_t thread_id, u32 entry, u64 arg, s32 prio, u32 s std::string threadname = ""; if (threadname_addr) threadname = Memory.ReadString(threadname_addr); - sysPrxForUser->Log("sys_ppu_thread_create(thread_id_addr=0x%x, entry=0x%x, arg=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname_addr=0x%x('%s'))", + sys_ppu_thread.Log("sys_ppu_thread_create(thread_id_addr=0x%x, entry=0x%x, arg=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname_addr=0x%x('%s'))", thread_id.GetAddr(), entry, arg, prio, stacksize, flags, threadname_addr, threadname.c_str()); bool is_joinable = false; @@ -175,7 +173,7 @@ s32 sys_ppu_thread_create(mem64_t thread_id, u32 entry, u64 arg, s32 prio, u32 s is_interrupt = true; break; } - default: sysPrxForUser->Error("sys_ppu_thread_create(): unknown flags value (0x%llx)", flags); return CELL_EPERM; + default: sys_ppu_thread.Error("sys_ppu_thread_create(): unknown flags value (0x%llx)", flags); return CELL_EPERM; } CPUThread& new_thread = Emu.GetCPU().AddThread(CPU_THREAD_PPU); @@ -190,7 +188,7 @@ s32 sys_ppu_thread_create(mem64_t thread_id, u32 entry, u64 arg, s32 prio, u32 s new_thread.m_is_interrupt = is_interrupt; new_thread.SetName(threadname); - LOG_NOTICE(PPU, "*** New PPU Thread [%s] (flags=0x%llx, entry=0x%x): id = %d", new_thread.GetName().c_str(), flags, entry, new_thread.GetId()); + sys_ppu_thread.Notice("*** New PPU Thread [%s] (flags=0x%llx, entry=0x%x): id = %d", new_thread.GetName().c_str(), flags, entry, new_thread.GetId()); if (!is_interrupt) { @@ -203,23 +201,18 @@ s32 sys_ppu_thread_create(mem64_t thread_id, u32 entry, u64 arg, s32 prio, u32 s void sys_ppu_thread_once(mem_ptr_t>> once_ctrl, u32 entry) { - sysPrxForUser->Warning("sys_ppu_thread_once(once_ctrl_addr=0x%x, entry=0x%x)", once_ctrl.GetAddr(), entry); + sys_ppu_thread.Warning("sys_ppu_thread_once(once_ctrl_addr=0x%x, entry=0x%x)", once_ctrl.GetAddr(), entry); be_t old = be_t::MakeFromBE(se32(SYS_PPU_THREAD_ONCE_INIT)); if (once_ctrl->compare_exchange_weak(old, be_t::MakeFromBE(se32(SYS_PPU_THREAD_DONE_INIT)))) { - CPUThread& new_thread = Emu.GetCPU().AddThread(CPU_THREAD_PPU); - new_thread.SetEntry(entry); - new_thread.Run(); - new_thread.Exec(); - - while (new_thread.IsAlive()) SM_Sleep(); + GetCurrentPPUThread().FastCall2(Memory.Read32(entry), Memory.Read32(entry + 4)); } } s32 sys_ppu_thread_get_id(const u32 id_addr) { - sysPrxForUser->Log("sys_ppu_thread_get_id(id_addr=0x%x)", id_addr); + sys_ppu_thread.Log("sys_ppu_thread_get_id(id_addr=0x%x)", id_addr); Memory.Write64(id_addr, GetCurrentPPUThread().GetId()); return CELL_OK; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_process.cpp b/rpcs3/Emu/SysCalls/lv2/sys_process.cpp index 02ff2174b6..0f0c4d0d54 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_process.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_process.cpp @@ -1,12 +1,12 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" + #include "sys_process.h" #include "rpcs3.h" -SysCallBase sc_p("Process"); +SysCallBase sys_process("sys_process"); s32 process_getpid() { @@ -16,21 +16,21 @@ s32 process_getpid() s32 sys_process_getpid() { - sc_p.Log("sys_process_getpid() -> 1"); + sys_process.Log("sys_process_getpid() -> 1"); return process_getpid(); } s32 sys_process_getppid() { - sc_p.Todo("sys_process_getppid() -> 0"); + sys_process.Todo("sys_process_getppid() -> 0"); return 0; } s32 sys_process_exit(s32 errorcode) { - sc_p.Warning("sys_process_exit(%d)", errorcode); + sys_process.Warning("sys_process_exit(%d)", errorcode); Emu.Pause(); - LOG_SUCCESS(HLE, "Process finished"); + sys_process.Success("Process finished"); wxGetApp().CallAfter([]() { Emu.Stop(); @@ -51,14 +51,14 @@ void sys_game_process_exitspawn( u32 prio, u64 flags ) { - sc_p.Todo("sys_game_process_exitspawn()"); - sc_p.Warning("path: %s", Memory.ReadString(path_addr).c_str()); - sc_p.Warning("argv: 0x%x", argv_addr); - sc_p.Warning("envp: 0x%x", envp_addr); - sc_p.Warning("data: 0x%x", data_addr); - sc_p.Warning("data_size: 0x%x", data_size); - sc_p.Warning("prio: %d", prio); - sc_p.Warning("flags: %d", flags); + sys_process.Todo("sys_game_process_exitspawn()"); + sys_process.Warning("path: %s", Memory.ReadString(path_addr).c_str()); + sys_process.Warning("argv: 0x%x", argv_addr); + sys_process.Warning("envp: 0x%x", envp_addr); + sys_process.Warning("data: 0x%x", data_addr); + sys_process.Warning("data_size: 0x%x", data_size); + sys_process.Warning("prio: %d", prio); + sys_process.Warning("flags: %d", flags); std::string path = Memory.ReadString(path_addr); std::vector argv; @@ -78,10 +78,10 @@ void sys_game_process_exitspawn( } for (auto &arg : argv){ - sc_p.Log("argument: %s", arg.c_str()); + sys_process.Log("argument: %s", arg.c_str()); } for (auto &en : env){ - sc_p.Log("env_argument: %s", en.c_str()); + sys_process.Log("env_argument: %s", en.c_str()); } //TODO: execute the file in with the args in argv //and the environment parameters in envp and copy the data @@ -99,14 +99,14 @@ void sys_game_process_exitspawn2( u32 prio, u64 flags) { - sc_p.Todo("sys_game_process_exitspawn2"); - sc_p.Warning("path: %s", Memory.ReadString(path_addr).c_str()); - sc_p.Warning("argv: 0x%x", argv_addr); - sc_p.Warning("envp: 0x%x", envp_addr); - sc_p.Warning("data: 0x%x", data_addr); - sc_p.Warning("data_size: 0x%x", data_size); - sc_p.Warning("prio: %d", prio); - sc_p.Warning("flags: %d", flags); + sys_process.Todo("sys_game_process_exitspawn2"); + sys_process.Warning("path: %s", Memory.ReadString(path_addr).c_str()); + sys_process.Warning("argv: 0x%x", argv_addr); + sys_process.Warning("envp: 0x%x", envp_addr); + sys_process.Warning("data: 0x%x", data_addr); + sys_process.Warning("data_size: 0x%x", data_size); + sys_process.Warning("prio: %d", prio); + sys_process.Warning("flags: %d", flags); std::string path = Memory.ReadString(path_addr); std::vector argv; @@ -126,10 +126,10 @@ void sys_game_process_exitspawn2( } for (auto &arg : argv){ - sc_p.Log("argument: %s", arg.c_str()); + sys_process.Log("argument: %s", arg.c_str()); } for (auto &en : env){ - sc_p.Log("env_argument: %s", en.c_str()); + sys_process.Log("env_argument: %s", en.c_str()); } //TODO: execute the file in with the args in argv //and the environment parameters in envp and copy the data @@ -140,7 +140,7 @@ void sys_game_process_exitspawn2( s32 sys_process_get_number_of_object(u32 object, mem32_t nump) { - sc_p.Warning("sys_process_get_number_of_object(object=%d, nump_addr=0x%x)", + sys_process.Warning("sys_process_get_number_of_object(object=%d, nump_addr=0x%x)", object, nump.GetAddr()); switch(object) @@ -175,7 +175,7 @@ s32 sys_process_get_number_of_object(u32 object, mem32_t nump) s32 sys_process_get_id(u32 object, mem32_ptr_t buffer, u32 size, mem32_t set_size) { - sc_p.Todo("sys_process_get_id(object=%d, buffer_addr=0x%x, size=%d, set_size_addr=0x%x)", + sys_process.Todo("sys_process_get_id(object=%d, buffer_addr=0x%x, size=%d, set_size_addr=0x%x)", object, buffer.GetAddr(), size, set_size.GetAddr()); switch(object) @@ -219,7 +219,7 @@ s32 sys_process_get_id(u32 object, mem32_ptr_t buffer, u32 size, mem32_t set_siz s32 sys_process_get_paramsfo(mem8_ptr_t buffer) { - sc_p.Todo("sys_process_get_paramsfo(buffer_addr=0x%x) -> CELL_ENOENT", buffer.GetAddr()); + sys_process.Todo("sys_process_get_paramsfo(buffer_addr=0x%x) -> CELL_ENOENT", buffer.GetAddr()); return CELL_ENOENT; /*//Before uncommenting this code, we should check if it is actually working. @@ -246,7 +246,7 @@ s32 process_get_sdk_version(u32 pid, s32& ver) s32 sys_process_get_sdk_version(u32 pid, mem32_t version) { - sc_p.Warning("sys_process_get_sdk_version(pid=%d, version_addr=0x%x)", pid, version.GetAddr()); + sys_process.Warning("sys_process_get_sdk_version(pid=%d, version_addr=0x%x)", pid, version.GetAddr()); s32 sdk_ver; s32 ret = process_get_sdk_version(pid, sdk_ver); @@ -263,33 +263,33 @@ s32 sys_process_get_sdk_version(u32 pid, mem32_t version) s32 sys_process_kill(u32 pid) { - sc_p.Todo("sys_process_kill(pid=%d)", pid); + sys_process.Todo("sys_process_kill(pid=%d)", pid); return CELL_OK; } s32 sys_process_wait_for_child(u32 pid, mem32_t status, u64 unk) { - sc_p.Todo("sys_process_wait_for_child(pid=%d, status_addr=0x%x, unk=0x%llx", + sys_process.Todo("sys_process_wait_for_child(pid=%d, status_addr=0x%x, unk=0x%llx", pid, status.GetAddr(), unk); return CELL_OK; } s32 sys_process_wait_for_child2(u64 unk1, u64 unk2, u64 unk3, u64 unk4, u64 unk5, u64 unk6) { - sc_p.Todo("sys_process_wait_for_child2(unk1=0x%llx, unk2=0x%llx, unk3=0x%llx, unk4=0x%llx, unk5=0x%llx, unk6=0x%llx)", + sys_process.Todo("sys_process_wait_for_child2(unk1=0x%llx, unk2=0x%llx, unk3=0x%llx, unk4=0x%llx, unk5=0x%llx, unk6=0x%llx)", unk1, unk2, unk3, unk4, unk5, unk6); return CELL_OK; } s32 sys_process_get_status(u64 unk) { - sc_p.Todo("sys_process_get_status(unk=0x%llx)", unk); + sys_process.Todo("sys_process_get_status(unk=0x%llx)", unk); //Memory.Write32(CPU.GPR[4], GetPPUThreadStatus(CPU)); return CELL_OK; } s32 sys_process_detach_child(u64 unk) { - sc_p.Todo("sys_process_detach_child(unk=0x%llx)", unk); + sys_process.Todo("sys_process_detach_child(unk=0x%llx)", unk); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp b/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp index 5e8370b730..1da8a4cf0b 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_prx.cpp @@ -1,8 +1,8 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" + #include "Emu/FS/vfsFile.h" #include "Crypto/unself.h" #include "sys_prx.h" diff --git a/rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp b/rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp index 1b65fdd5ea..7ffba5fd2c 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_rsx.cpp @@ -1,8 +1,8 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" + #include "sys_rsx.h" SysCallBase sys_rsx("sys_rsx"); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp index 593b0ad532..187349b5a2 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.cpp @@ -1,8 +1,10 @@ #include "stdafx.h" -#include "Utilities/Log.h" -#include "Emu/Cell/PPUThread.h" +#include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" + +#include "Emu/Cell/PPUThread.h" +#include "sys_lwmutex.h" #include "sys_rwlock.h" SysCallBase sys_rwlock("sys_rwlock"); @@ -69,7 +71,7 @@ s32 sys_rwlock_rlock(u32 rw_lock_id, u64 timeout) { if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_rwlock_rlock(rw_lock_id=%d, ...) aborted", rw_lock_id); + sys_rwlock.Warning("sys_rwlock_rlock(rw_lock_id=%d, ...) aborted", rw_lock_id); return CELL_ETIMEDOUT; } std::this_thread::sleep_for(std::chrono::milliseconds(1)); @@ -132,7 +134,7 @@ s32 sys_rwlock_wlock(u32 rw_lock_id, u64 timeout) { if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_rwlock_wlock(rw_lock_id=%d, ...) aborted", rw_lock_id); + sys_rwlock.Warning("sys_rwlock_wlock(rw_lock_id=%d, ...) aborted", rw_lock_id); return CELL_ETIMEDOUT; } std::this_thread::sleep_for(std::chrono::milliseconds(1)); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp index d402105eee..aebb57dff7 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp @@ -1,28 +1,29 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" + #include "Emu/Cell/PPUThread.h" #include "sys_semaphore.h" #include "sys_time.h" +//#include "Utilities/SMutex.h" -SysCallBase sys_sem("sys_semaphore"); +SysCallBase sys_semaphore("sys_semaphore"); s32 sys_semaphore_create(mem32_t sem, mem_ptr_t attr, int initial_count, int max_count) { - sys_sem.Warning("sys_semaphore_create(sem_addr=0x%x, attr_addr=0x%x, initial_count=%d, max_count=%d)", + sys_semaphore.Warning("sys_semaphore_create(sem_addr=0x%x, attr_addr=0x%x, initial_count=%d, max_count=%d)", sem.GetAddr(), attr.GetAddr(), initial_count, max_count); if (max_count <= 0 || initial_count > max_count || initial_count < 0) { - sys_sem.Error("sys_semaphore_create(): invalid parameters (initial_count=%d, max_count=%d)", initial_count, max_count); + sys_semaphore.Error("sys_semaphore_create(): invalid parameters (initial_count=%d, max_count=%d)", initial_count, max_count); return CELL_EINVAL; } if (attr->pshared.ToBE() != se32(0x200)) { - sys_sem.Error("sys_semaphore_create(): invalid pshared value(0x%x)", (u32)attr->pshared); + sys_semaphore.Error("sys_semaphore_create(): invalid pshared value(0x%x)", (u32)attr->pshared); return CELL_EINVAL; } @@ -30,13 +31,13 @@ s32 sys_semaphore_create(mem32_t sem, mem_ptr_t attr, i { case se32(SYS_SYNC_FIFO): break; case se32(SYS_SYNC_PRIORITY): break; - case se32(SYS_SYNC_PRIORITY_INHERIT): sys_sem.Todo("SYS_SYNC_PRIORITY_INHERIT"); break; - case se32(SYS_SYNC_RETRY): sys_sem.Error("SYS_SYNC_RETRY"); return CELL_EINVAL; - default: sys_sem.Error("Unknown protocol attribute(0x%x)", (u32)attr->protocol); return CELL_EINVAL; + case se32(SYS_SYNC_PRIORITY_INHERIT): sys_semaphore.Todo("SYS_SYNC_PRIORITY_INHERIT"); break; + case se32(SYS_SYNC_RETRY): sys_semaphore.Error("SYS_SYNC_RETRY"); return CELL_EINVAL; + default: sys_semaphore.Error("Unknown protocol attribute(0x%x)", (u32)attr->protocol); return CELL_EINVAL; } - sem = sys_sem.GetNewId(new Semaphore(initial_count, max_count, attr->protocol, attr->name_u64), TYPE_SEMAPHORE); - LOG_NOTICE(HLE, "*** semaphore created [%s] (protocol=0x%x): id = %d", + sem = sys_semaphore.GetNewId(new Semaphore(initial_count, max_count, attr->protocol, attr->name_u64), TYPE_SEMAPHORE); + sys_semaphore.Notice("*** semaphore created [%s] (protocol=0x%x): id = %d", std::string(attr->name, 8).c_str(), (u32)attr->protocol, sem.GetValue()); return CELL_OK; @@ -44,7 +45,7 @@ s32 sys_semaphore_create(mem32_t sem, mem_ptr_t attr, i s32 sys_semaphore_destroy(u32 sem_id) { - sys_sem.Warning("sys_semaphore_destroy(sem_id=%d)", sem_id); + sys_semaphore.Warning("sys_semaphore_destroy(sem_id=%d)", sem_id); Semaphore* sem; if (!Emu.GetIdManager().GetIDData(sem_id, sem)) @@ -63,7 +64,7 @@ s32 sys_semaphore_destroy(u32 sem_id) s32 sys_semaphore_wait(u32 sem_id, u64 timeout) { - sys_sem.Log("sys_semaphore_wait(sem_id=%d, timeout=%lld)", sem_id, timeout); + sys_semaphore.Log("sys_semaphore_wait(sem_id=%d, timeout=%lld)", sem_id, timeout); Semaphore* sem; if (!Emu.GetIdManager().GetIDData(sem_id, sem)) @@ -88,7 +89,7 @@ s32 sys_semaphore_wait(u32 sem_id, u64 timeout) { if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_semaphore_wait(%d) aborted", sem_id); + sys_semaphore.Warning("sys_semaphore_wait(%d) aborted", sem_id); return CELL_OK; } @@ -117,7 +118,7 @@ s32 sys_semaphore_wait(u32 sem_id, u64 timeout) s32 sys_semaphore_trywait(u32 sem_id) { - sys_sem.Log("sys_semaphore_trywait(sem_id=%d)", sem_id); + sys_semaphore.Log("sys_semaphore_trywait(sem_id=%d)", sem_id); Semaphore* sem; if (!Emu.GetIdManager().GetIDData(sem_id, sem)) @@ -140,7 +141,7 @@ s32 sys_semaphore_trywait(u32 sem_id) s32 sys_semaphore_post(u32 sem_id, int count) { - sys_sem.Log("sys_semaphore_post(sem_id=%d, count=%d)", sem_id, count); + sys_semaphore.Log("sys_semaphore_post(sem_id=%d, count=%d)", sem_id, count); Semaphore* sem; if (!Emu.GetIdManager().GetIDData(sem_id, sem)) @@ -162,7 +163,7 @@ s32 sys_semaphore_post(u32 sem_id, int count) { if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_semaphore_post(%d) aborted", sem_id); + sys_semaphore.Warning("sys_semaphore_post(%d) aborted", sem_id); return CELL_OK; } @@ -192,7 +193,7 @@ s32 sys_semaphore_post(u32 sem_id, int count) s32 sys_semaphore_get_value(u32 sem_id, mem32_t count) { - sys_sem.Log("sys_semaphore_get_value(sem_id=%d, count_addr=0x%x)", sem_id, count.GetAddr()); + sys_semaphore.Log("sys_semaphore_get_value(sem_id=%d, count_addr=0x%x)", sem_id, count.GetAddr()); Semaphore* sem; if (!Emu.GetIdManager().GetIDData(sem_id, sem)) diff --git a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h index 653f46502a..e78165d989 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h @@ -1,5 +1,7 @@ #pragma once +#include "sys_lwmutex.h" + struct sys_semaphore_attribute { be_t protocol; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_spinlock.cpp b/rpcs3/Emu/SysCalls/lv2/sys_spinlock.cpp index 26462efd71..454b23572b 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_spinlock.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_spinlock.cpp @@ -1,8 +1,6 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "Emu/Cell/PPUThread.h" #include "Emu/SysCalls/SysCalls.h" #include "sys_spinlock.h" @@ -35,7 +33,7 @@ void sys_spinlock_lock(mem_ptr_t>> lock) if (Emu.IsStopped()) { - LOG_WARNING(HLE, "sys_spinlock_lock(0x%x) aborted", lock.GetAddr()); + sys_spinlock.Warning("sys_spinlock_lock(0x%x) aborted", lock.GetAddr()); break; } } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp b/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp index e14a3948b1..ddc53e80e7 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp @@ -1,15 +1,15 @@ #include "stdafx.h" -#include "Emu/System.h" #include "Emu/Memory/Memory.h" -#include "Emu/FS/vfsFile.h" -#include "sys_spu.h" +#include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" -#include "Loader/ELF.h" + #include "Emu/Cell/RawSPUThread.h" +#include "Emu/FS/vfsFile.h" +#include "Loader/ELF.h" +#include "sys_spu.h" #include -static SysCallBase sc_spu("sys_spu"); -extern SysCallBase sys_event; +static SysCallBase sys_spu("sys_spu"); u32 LoadSpuImage(vfsStream& stream, u32& spu_ep) { @@ -26,12 +26,12 @@ u32 LoadSpuImage(vfsStream& stream, u32& spu_ep) s32 sys_spu_image_open(mem_ptr_t img, u32 path_addr) { const std::string path = Memory.ReadString(path_addr); - sc_spu.Warning("sys_spu_image_open(img_addr=0x%x, path_addr=0x%x [%s])", img.GetAddr(), path_addr, path.c_str()); + sys_spu.Warning("sys_spu_image_open(img_addr=0x%x, path_addr=0x%x [%s])", img.GetAddr(), path_addr, path.c_str()); vfsFile f(path); if(!f.IsOpened()) { - sc_spu.Error("sys_spu_image_open error: '%s' not found!", path.c_str()); + sys_spu.Error("sys_spu_image_open error: '%s' not found!", path.c_str()); return CELL_ENOENT; } @@ -49,7 +49,7 @@ s32 sys_spu_image_open(mem_ptr_t img, u32 path_addr) //172 s32 sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t img, mem_ptr_t attr, mem_ptr_t arg) { - sc_spu.Warning("sys_spu_thread_initialize(thread_addr=0x%x, group=0x%x, spu_num=%d, img_addr=0x%x, attr_addr=0x%x, arg_addr=0x%x)", + sys_spu.Warning("sys_spu_thread_initialize(thread_addr=0x%x, group=0x%x, spu_num=%d, img_addr=0x%x, attr_addr=0x%x, arg_addr=0x%x)", thread.GetAddr(), group, spu_num, img.GetAddr(), attr.GetAddr(), arg.GetAddr()); SpuGroupInfo* group_info; @@ -99,7 +99,7 @@ s32 sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t< thread = group_info->list[spu_num] = new_thread.GetId(); (*(SPUThread*)&new_thread).group = group_info; - sc_spu.Warning("*** New SPU Thread [%s] (img_offset=0x%x, ls_offset=0x%x, ep=0x%x, a1=0x%llx, a2=0x%llx, a3=0x%llx, a4=0x%llx): id=%d", + sys_spu.Warning("*** New SPU Thread [%s] (img_offset=0x%x, ls_offset=0x%x, ep=0x%x, a1=0x%llx, a2=0x%llx, a3=0x%llx, a4=0x%llx): id=%d", (attr->name_addr ? name.c_str() : ""), (u32) img->segs_addr, ((SPUThread&) new_thread).dmac.ls_offset, spu_ep, a1, a2, a3, a4, thread.GetValue()); return CELL_OK; @@ -108,7 +108,7 @@ s32 sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t< //166 s32 sys_spu_thread_set_argument(u32 id, mem_ptr_t arg) { - sc_spu.Warning("sys_spu_thread_set_argument(id=%d, arg_addr=0x%x)", id, arg.GetAddr()); + sys_spu.Warning("sys_spu_thread_set_argument(id=%d, arg_addr=0x%x)", id, arg.GetAddr()); CPUThread* thr = Emu.GetCPU().GetThread(id); if(!thr || thr->GetType() != CPU_THREAD_SPU) @@ -127,7 +127,7 @@ s32 sys_spu_thread_set_argument(u32 id, mem_ptr_t arg) //165 s32 sys_spu_thread_get_exit_status(u32 id, mem32_t status) { - sc_spu.Warning("sys_spu_thread_get_exit_status(id=%d, status_addr=0x%x)", id, status.GetAddr()); + sys_spu.Warning("sys_spu_thread_get_exit_status(id=%d, status_addr=0x%x)", id, status.GetAddr()); CPUThread* thr = Emu.GetCPU().GetThread(id); @@ -149,7 +149,7 @@ s32 sys_spu_thread_get_exit_status(u32 id, mem32_t status) //171 s32 sys_spu_thread_group_destroy(u32 id) { - sc_spu.Warning("sys_spu_thread_group_destroy(id=%d)", id); + sys_spu.Warning("sys_spu_thread_group_destroy(id=%d)", id); SpuGroupInfo* group_info; if(!Emu.GetIdManager().GetIDData(id, group_info)) @@ -165,7 +165,7 @@ s32 sys_spu_thread_group_destroy(u32 id) if ((group_info->m_state != SPU_THREAD_GROUP_STATUS_INITIALIZED) && (group_info->m_state != SPU_THREAD_GROUP_STATUS_NOT_INITIALIZED)) { - sc_spu.Error("sys_spu_thread_group_destroy(id=%d) is not in NOT_INITIALIZED / INITIALIZED, state=%d", id, group_info->m_state); + sys_spu.Error("sys_spu_thread_group_destroy(id=%d) is not in NOT_INITIALIZED / INITIALIZED, state=%d", id, group_info->m_state); return CELL_ESTAT; //Indeed this should not be encountered. If program itself all right. } //SET BUSY @@ -188,7 +188,7 @@ s32 sys_spu_thread_group_destroy(u32 id) //173 s32 sys_spu_thread_group_start(u32 id) { - sc_spu.Warning("sys_spu_thread_group_start(id=%d)", id); + sys_spu.Warning("sys_spu_thread_group_start(id=%d)", id); SpuGroupInfo* group_info; if(!Emu.GetIdManager().GetIDData(id, group_info)) @@ -224,7 +224,7 @@ s32 sys_spu_thread_group_start(u32 id) //174 s32 sys_spu_thread_group_suspend(u32 id) { - sc_spu.Log("sys_spu_thread_group_suspend(id=%d)", id); + sys_spu.Log("sys_spu_thread_group_suspend(id=%d)", id); SpuGroupInfo* group_info; if(!Emu.GetIdManager().GetIDData(id, group_info)) @@ -271,7 +271,7 @@ s32 sys_spu_thread_group_suspend(u32 id) //175 s32 sys_spu_thread_group_resume(u32 id) { - sc_spu.Log("sys_spu_thread_group_resume(id=%d)", id); + sys_spu.Log("sys_spu_thread_group_resume(id=%d)", id); SpuGroupInfo* group_info; if(!Emu.GetIdManager().GetIDData(id, group_info)) @@ -319,7 +319,7 @@ s32 sys_spu_thread_group_resume(u32 id) //176: Left doing nothing, indeed s32 sys_spu_thread_group_yield(u32 id) { - sc_spu.Error("sys_spu_thread_group_yield(id=%d)", id); + sys_spu.Error("sys_spu_thread_group_yield(id=%d)", id); SpuGroupInfo* group_info; if (!Emu.GetIdManager().GetIDData(id, group_info)) @@ -362,7 +362,7 @@ s32 sys_spu_thread_group_yield(u32 id) //177: Left omit the EPERM check. s32 sys_spu_thread_group_terminate(u32 id, int value) { - sc_spu.Error("sys_spu_thread_group_terminate(id=%d, value=%d)", id, value); + sys_spu.Error("sys_spu_thread_group_terminate(id=%d, value=%d)", id, value); SpuGroupInfo* group_info; if (!Emu.GetIdManager().GetIDData(id, group_info)) @@ -401,7 +401,7 @@ s32 sys_spu_thread_group_terminate(u32 id, int value) //170 s32 sys_spu_thread_group_create(mem32_t id, u32 num, int prio, mem_ptr_t attr) { - sc_spu.Warning("sys_spu_thread_group_create(id_addr=0x%x, num=%d, prio=%d, attr_addr=0x%x)", + sys_spu.Warning("sys_spu_thread_group_create(id_addr=0x%x, num=%d, prio=%d, attr_addr=0x%x)", id.GetAddr(), num, prio, attr.GetAddr()); if (num > 256) return CELL_EINVAL; @@ -410,9 +410,9 @@ s32 sys_spu_thread_group_create(mem32_t id, u32 num, int prio, mem_ptr_tname_addr, attr->name_len); - id = sc_spu.GetNewId(new SpuGroupInfo(name, num, prio, attr->type, attr->ct)); + id = sys_spu.GetNewId(new SpuGroupInfo(name, num, prio, attr->type, attr->ct)); - sc_spu.Warning("*** SPU Thread Group created [%s] (type=0x%x, option.ct=0x%x): id=%d", + sys_spu.Warning("*** SPU Thread Group created [%s] (type=0x%x, option.ct=0x%x): id=%d", name.c_str(), (int)attr->type, (u32)attr->ct, id.GetValue()); return CELL_OK; @@ -421,7 +421,7 @@ s32 sys_spu_thread_group_create(mem32_t id, u32 num, int prio, mem_ptr_t 5) { @@ -482,7 +482,7 @@ s32 sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu) //181 s32 sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type) { - sc_spu.Log("sys_spu_thread_write_ls(id=%d, address=0x%x, value=0x%llx, type=0x%x)", + sys_spu.Log("sys_spu_thread_write_ls(id=%d, address=0x%x, value=0x%llx, type=0x%x)", id, address, value, type); CPUThread* thr = Emu.GetCPU().GetThread(id); @@ -515,7 +515,7 @@ s32 sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type) //182 s32 sys_spu_thread_read_ls(u32 id, u32 address, mem64_t value, u32 type) { - sc_spu.Log("sys_spu_thread_read_ls(id=%d, address=0x%x, value_addr=0x%x, type=0x%x)", + sys_spu.Log("sys_spu_thread_read_ls(id=%d, address=0x%x, value_addr=0x%x, type=0x%x)", id, address, value.GetAddr(), type); CPUThread* thr = Emu.GetCPU().GetThread(id); @@ -548,7 +548,7 @@ s32 sys_spu_thread_read_ls(u32 id, u32 address, mem64_t value, u32 type) //190 s32 sys_spu_thread_write_spu_mb(u32 id, u32 value) { - sc_spu.Log("sys_spu_thread_write_spu_mb(id=%d, value=0x%x)", id, value); + sys_spu.Log("sys_spu_thread_write_spu_mb(id=%d, value=0x%x)", id, value); CPUThread* thr = Emu.GetCPU().GetThread(id); @@ -565,7 +565,7 @@ s32 sys_spu_thread_write_spu_mb(u32 id, u32 value) //187 s32 sys_spu_thread_set_spu_cfg(u32 id, u64 value) { - sc_spu.Warning("sys_spu_thread_set_spu_cfg(id=%d, value=0x%x)", id, value); + sys_spu.Warning("sys_spu_thread_set_spu_cfg(id=%d, value=0x%x)", id, value); CPUThread* thr = Emu.GetCPU().GetThread(id); @@ -587,7 +587,7 @@ s32 sys_spu_thread_set_spu_cfg(u32 id, u64 value) //188 s32 sys_spu_thread_get_spu_cfg(u32 id, mem64_t value) { - sc_spu.Warning("sys_spu_thread_get_spu_cfg(id=%d, value_addr=0x%x)", id, value.GetAddr()); + sys_spu.Warning("sys_spu_thread_get_spu_cfg(id=%d, value_addr=0x%x)", id, value.GetAddr()); CPUThread* thr = Emu.GetCPU().GetThread(id); @@ -604,7 +604,7 @@ s32 sys_spu_thread_get_spu_cfg(u32 id, mem64_t value) //184 s32 sys_spu_thread_write_snr(u32 id, u32 number, u32 value) { - sc_spu.Log("sys_spu_thread_write_snr(id=%d, number=%d, value=0x%x)", id, number, value); + sys_spu.Log("sys_spu_thread_write_snr(id=%d, number=%d, value=0x%x)", id, number, value); CPUThread* thr = Emu.GetCPU().GetThread(id); if(!thr || thr->GetType() != CPU_THREAD_SPU) @@ -624,14 +624,14 @@ s32 sys_spu_thread_write_snr(u32 id, u32 number, u32 value) s32 sys_spu_thread_group_connect_event(u32 id, u32 eq, u32 et) { - sc_spu.Todo("sys_spu_thread_group_connect_event(id=%d, eq=%d, et=0x%x)", id, eq, et); + sys_spu.Todo("sys_spu_thread_group_connect_event(id=%d, eq=%d, et=0x%x)", id, eq, et); return CELL_OK; } s32 sys_spu_thread_group_disconnect_event(u32 id, u32 et) { - sc_spu.Todo("sys_spu_thread_group_disconnect_event(id=%d, et=0x%x)", id, et); + sys_spu.Todo("sys_spu_thread_group_disconnect_event(id=%d, et=0x%x)", id, et); return CELL_OK; } @@ -646,7 +646,7 @@ s32 sys_spu_thread_tryreceive_event(u32 spuq_num, mem32_t d1, mem32_t d2, mem32_ s32 sys_spu_thread_connect_event(u32 id, u32 eq_id, u32 et, u8 spup) { - sc_spu.Warning("sys_spu_thread_connect_event(id=%d, eq_id=%d, event_type=0x%x, spup=%d)", id, eq_id, et, spup); + sys_spu.Warning("sys_spu_thread_connect_event(id=%d, eq_id=%d, event_type=0x%x, spup=%d)", id, eq_id, et, spup); CPUThread* thr = Emu.GetCPU().GetThread(id); @@ -663,13 +663,13 @@ s32 sys_spu_thread_connect_event(u32 id, u32 eq_id, u32 et, u8 spup) if (spup > 63) { - sc_spu.Error("sys_spu_thread_connect_event: invalid spup (%d)", spup); + sys_spu.Error("sys_spu_thread_connect_event: invalid spup (%d)", spup); return CELL_EINVAL; } if (et != SYS_SPU_THREAD_EVENT_USER) { - sc_spu.Error("sys_spu_thread_connect_event: unsupported event type (0x%x)", et); + sys_spu.Error("sys_spu_thread_connect_event: unsupported event type (0x%x)", et); return CELL_EINVAL; } @@ -695,7 +695,7 @@ s32 sys_spu_thread_connect_event(u32 id, u32 eq_id, u32 et, u8 spup) // s32 sys_spu_thread_disconnect_event(u32 id, u32 et, u8 spup) { - sc_spu.Warning("sys_spu_thread_disconnect_event(id=%d, event_type=0x%x, spup=%d)", id, et, spup); + sys_spu.Warning("sys_spu_thread_disconnect_event(id=%d, event_type=0x%x, spup=%d)", id, et, spup); CPUThread* thr = Emu.GetCPU().GetThread(id); @@ -706,13 +706,13 @@ s32 sys_spu_thread_disconnect_event(u32 id, u32 et, u8 spup) if (spup > 63) { - sc_spu.Error("sys_spu_thread_connect_event: invalid spup (%d)", spup); + sys_spu.Error("sys_spu_thread_connect_event: invalid spup (%d)", spup); return CELL_EINVAL; } if (et != SYS_SPU_THREAD_EVENT_USER) { - sc_spu.Error("sys_spu_thread_connect_event: unsupported event type (0x%x)", et); + sys_spu.Error("sys_spu_thread_connect_event: unsupported event type (0x%x)", et); return CELL_EINVAL; } @@ -735,7 +735,7 @@ s32 sys_spu_thread_disconnect_event(u32 id, u32 et, u8 spup) s32 sys_spu_thread_bind_queue(u32 id, u32 eq_id, u32 spuq_num) { - sc_spu.Warning("sys_spu_thread_bind_queue(id=%d, equeue_id=%d, spuq_num=0x%x)", id, eq_id, spuq_num); + sys_spu.Warning("sys_spu_thread_bind_queue(id=%d, equeue_id=%d, spuq_num=0x%x)", id, eq_id, spuq_num); EventQueue* eq; if (!Emu.GetIdManager().GetIDData(eq_id, eq)) @@ -765,7 +765,7 @@ s32 sys_spu_thread_bind_queue(u32 id, u32 eq_id, u32 spuq_num) s32 sys_spu_thread_unbind_queue(u32 id, u32 spuq_num) { - sc_spu.Warning("sys_spu_thread_unbind_queue(id=0x%x, spuq_num=0x%x)", id, spuq_num); + sys_spu.Warning("sys_spu_thread_unbind_queue(id=0x%x, spuq_num=0x%x)", id, spuq_num); CPUThread* thr = Emu.GetCPU().GetThread(id); @@ -784,7 +784,7 @@ s32 sys_spu_thread_unbind_queue(u32 id, u32 spuq_num) s32 sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq_id, u64 req, mem8_t spup) { - sc_spu.Warning("sys_spu_thread_group_connect_event_all_threads(id=%d, eq_id=%d, req=0x%llx, spup_addr=0x%x)", + sys_spu.Warning("sys_spu_thread_group_connect_event_all_threads(id=%d, eq_id=%d, req=0x%llx, spup_addr=0x%x)", id, eq_id, req, spup.GetAddr()); EventQueue* eq; @@ -811,7 +811,7 @@ s32 sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq_id, u64 req, m CPUThread* thr = Emu.GetCPU().GetThread(v); if (thr->GetType() != CPU_THREAD_SPU) { - sc_spu.Error("sys_spu_thread_group_connect_event_all_threads(): CELL_ESTAT (wrong thread type)"); + sys_spu.Error("sys_spu_thread_group_connect_event_all_threads(): CELL_ESTAT (wrong thread type)"); return CELL_ESTAT; } threads.push_back((SPUThread*)thr); @@ -819,7 +819,7 @@ s32 sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq_id, u64 req, m if (threads.size() != group->m_count) { - sc_spu.Error("sys_spu_thread_group_connect_event_all_threads(): CELL_ESTAT (%d from %d)", (u32)threads.size(), group->m_count); + sys_spu.Error("sys_spu_thread_group_connect_event_all_threads(): CELL_ESTAT (%d from %d)", (u32)threads.size(), group->m_count); return CELL_ESTAT; } @@ -839,7 +839,7 @@ s32 sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq_id, u64 req, m eq->ports.add(&(t->SPUPs[i])); t->SPUPs[i].eq = eq; } - sc_spu.Warning("*** spup -> %d", i); + sys_spu.Warning("*** spup -> %d", i); spup = (u8)i; } @@ -858,7 +858,7 @@ s32 sys_spu_thread_group_connect_event_all_threads(u32 id, u32 eq_id, u64 req, m s32 sys_spu_thread_group_disconnect_event_all_threads(u32 id, u8 spup) { - sc_spu.Todo("sys_spu_thread_group_disconnect_event_all_threads(id=%d, spup=%d)", id, spup); + sys_spu.Todo("sys_spu_thread_group_disconnect_event_all_threads(id=%d, spup=%d)", id, spup); return CELL_OK; } @@ -866,7 +866,7 @@ s32 sys_spu_thread_group_disconnect_event_all_threads(u32 id, u8 spup) //160 s32 sys_raw_spu_create(mem32_t id, u32 attr_addr) { - sc_spu.Warning("sys_raw_spu_create(id_addr=0x%x, attr_addr=0x%x)", id.GetAddr(), attr_addr); + sys_spu.Warning("sys_raw_spu_create(id_addr=0x%x, attr_addr=0x%x)", id.GetAddr(), attr_addr); CPUThread& new_thread = Emu.GetCPU().AddThread(CPU_THREAD_RAW_SPU); if (((RawSPUThread&)new_thread).GetIndex() >= 5) @@ -882,7 +882,7 @@ s32 sys_raw_spu_create(mem32_t id, u32 attr_addr) s32 sys_raw_spu_destroy(u32 id) { - sc_spu.Warning("sys_raw_spu_destroy(id=%d)", id); + sys_spu.Warning("sys_raw_spu_destroy(id=%d)", id); RawSPUThread* t = Emu.GetCPU().GetRawSPUThread(id); @@ -899,7 +899,7 @@ s32 sys_raw_spu_destroy(u32 id) s32 sys_raw_spu_create_interrupt_tag(u32 id, u32 class_id, u32 hwthread, mem32_t intrtag) { - sc_spu.Warning("sys_raw_spu_create_interrupt_tag(id=%d, class_id=%d, hwthread=0x%x, intrtag_addr=0x%x)", id, class_id, hwthread, intrtag.GetAddr()); + sys_spu.Warning("sys_raw_spu_create_interrupt_tag(id=%d, class_id=%d, hwthread=0x%x, intrtag_addr=0x%x)", id, class_id, hwthread, intrtag.GetAddr()); RawSPUThread* t = Emu.GetCPU().GetRawSPUThread(id); @@ -926,7 +926,7 @@ s32 sys_raw_spu_create_interrupt_tag(u32 id, u32 class_id, u32 hwthread, mem32_t s32 sys_raw_spu_set_int_mask(u32 id, u32 class_id, u64 mask) { - sc_spu.Warning("sys_raw_spu_set_int_mask(id=%d, class_id=%d, mask=0x%llx)", id, class_id, mask); + sys_spu.Warning("sys_raw_spu_set_int_mask(id=%d, class_id=%d, mask=0x%llx)", id, class_id, mask); RawSPUThread* t = Emu.GetCPU().GetRawSPUThread(id); if (!t) @@ -945,7 +945,7 @@ s32 sys_raw_spu_set_int_mask(u32 id, u32 class_id, u64 mask) s32 sys_raw_spu_get_int_mask(u32 id, u32 class_id, mem64_t mask) { - sc_spu.Log("sys_raw_spu_get_int_mask(id=%d, class_id=%d, mask_addr=0x%x)", id, class_id, mask.GetAddr()); + sys_spu.Log("sys_raw_spu_get_int_mask(id=%d, class_id=%d, mask_addr=0x%x)", id, class_id, mask.GetAddr()); RawSPUThread* t = Emu.GetCPU().GetRawSPUThread(id); if (!t) @@ -964,7 +964,7 @@ s32 sys_raw_spu_get_int_mask(u32 id, u32 class_id, mem64_t mask) s32 sys_raw_spu_set_int_stat(u32 id, u32 class_id, u64 stat) { - sc_spu.Log("sys_raw_spu_set_int_stat(id=%d, class_id=%d, stat=0x%llx)", id, class_id, stat); + sys_spu.Log("sys_raw_spu_set_int_stat(id=%d, class_id=%d, stat=0x%llx)", id, class_id, stat); RawSPUThread* t = Emu.GetCPU().GetRawSPUThread(id); if (!t) @@ -983,7 +983,7 @@ s32 sys_raw_spu_set_int_stat(u32 id, u32 class_id, u64 stat) s32 sys_raw_spu_get_int_stat(u32 id, u32 class_id, mem64_t stat) { - sc_spu.Log("sys_raw_spu_get_int_stat(id=%d, class_id=%d, stat_addr=0xx)", id, class_id, stat.GetAddr()); + sys_spu.Log("sys_raw_spu_get_int_stat(id=%d, class_id=%d, stat_addr=0xx)", id, class_id, stat.GetAddr()); RawSPUThread* t = Emu.GetCPU().GetRawSPUThread(id); if (!t) @@ -1002,7 +1002,7 @@ s32 sys_raw_spu_get_int_stat(u32 id, u32 class_id, mem64_t stat) s32 sys_raw_spu_read_puint_mb(u32 id, mem32_t value) { - sc_spu.Log("sys_raw_spu_read_puint_mb(id=%d, value_addr=0x%x)", id, value.GetAddr()); + sys_spu.Log("sys_raw_spu_read_puint_mb(id=%d, value_addr=0x%x)", id, value.GetAddr()); RawSPUThread* t = Emu.GetCPU().GetRawSPUThread(id); if (!t) @@ -1018,7 +1018,7 @@ s32 sys_raw_spu_read_puint_mb(u32 id, mem32_t value) s32 sys_raw_spu_set_spu_cfg(u32 id, u32 value) { - sc_spu.Log("sys_raw_spu_set_spu_cfg(id=%d, value=0x%x)", id, value); + sys_spu.Log("sys_raw_spu_set_spu_cfg(id=%d, value=0x%x)", id, value); RawSPUThread* t = Emu.GetCPU().GetRawSPUThread(id); if (!t) @@ -1032,7 +1032,7 @@ s32 sys_raw_spu_set_spu_cfg(u32 id, u32 value) s32 sys_raw_spu_get_spu_cfg(u32 id, mem32_t value) { - sc_spu.Log("sys_raw_spu_get_spu_afg(id=%d, value_addr=0x%x)", id, value.GetAddr()); + sys_spu.Log("sys_raw_spu_get_spu_afg(id=%d, value_addr=0x%x)", id, value.GetAddr()); RawSPUThread* t = Emu.GetCPU().GetRawSPUThread(id); if (!t) diff --git a/rpcs3/Emu/SysCalls/lv2/sys_time.cpp b/rpcs3/Emu/SysCalls/lv2/sys_time.cpp index 69292b5fed..90be5d2122 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_time.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_time.cpp @@ -6,10 +6,10 @@ * GNU LGPL 2.1 license * */ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" + #include "sys_time.h" SysCallBase sys_time("sys_time"); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp b/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp index 1597c098ee..7250394698 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" + +#include "Emu/Event.h" #include "sys_timer.h" SysCallBase sys_timer("sys_timer"); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_trace.cpp b/rpcs3/Emu/SysCalls/lv2/sys_trace.cpp index 725cb49338..7e6b76e7d1 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_trace.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_trace.cpp @@ -1,8 +1,8 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" + #include "sys_trace.h" SysCallBase sys_trace("sys_trace"); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_tty.cpp b/rpcs3/Emu/SysCalls/lv2/sys_tty.cpp index a570630de0..86548b31e4 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_tty.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_tty.cpp @@ -3,12 +3,16 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" + #include "sys_tty.h" +SysCallBase sys_tty("sys_tty"); + s32 sys_tty_read(u32 ch, u64 buf_addr, u32 len, u64 preadlen_addr) { + sys_tty.Error("sys_tty_read(ch=%d, buf_addr=%llx, len=%d, preadlen_addr=0x%llx)", ch, buf_addr, len, preadlen_addr); + // We currently do not support reading from the Console - LOG_WARNING(HLE, "sys_tty_read: ch: %d, buf addr: %llx, len: %d", ch, buf_addr, len); Memory.Write32(preadlen_addr, len); Emu.Pause(); @@ -17,6 +21,8 @@ s32 sys_tty_read(u32 ch, u64 buf_addr, u32 len, u64 preadlen_addr) s32 sys_tty_write(u32 ch, u64 buf_addr, u32 len, u64 pwritelen_addr) { + sys_tty.Log("sys_tty_write(ch=%d, buf_addr=%llx, len=%d, preadlen_addr=0x%llx)", ch, buf_addr, len, pwritelen_addr); + if(ch > 15 || (s32)len <= 0) return CELL_EINVAL; if (ch == SYS_TTYP_PPU_STDOUT || ch == SYS_TTYP_SPU_STDOUT || (ch >= SYS_TTYP_USER1 && ch <= SYS_TTYP_USER13)) { diff --git a/rpcs3/Emu/SysCalls/lv2/sys_vm.cpp b/rpcs3/Emu/SysCalls/lv2/sys_vm.cpp index 3c1de7c437..9fd3e39b2d 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_vm.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_vm.cpp @@ -1,16 +1,17 @@ #include "stdafx.h" -#include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" -#include "sys_memory.h" -SysCallBase sc_vm("vm"); +#include "sys_memory.h" +#include "sys_vm.h" + +SysCallBase sys_vm("vm"); MemoryContainerInfo* current_ct; s32 sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, u32 addr) { - sc_vm.Warning("sys_vm_memory_map(vsize=0x%x,psize=0x%x,cidr=0x%x,flags=0x%llx,policy=0x%llx,addr=0x%x)", + sys_vm.Warning("sys_vm_memory_map(vsize=0x%x,psize=0x%x,cidr=0x%x,flags=0x%llx,policy=0x%llx,addr=0x%x)", vsize, psize, cid, flag, policy, addr); // Check virtual size. @@ -51,7 +52,7 @@ s32 sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, u32 a { // Check memory container. MemoryContainerInfo* ct; - if(!sc_vm.CheckId(cid, ct)) return CELL_ESRCH; + if(!sys_vm.CheckId(cid, ct)) return CELL_ESRCH; current_ct = ct; } @@ -64,7 +65,7 @@ s32 sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy, u32 a s32 sys_vm_unmap(u32 addr) { - sc_vm.Warning("sys_vm_unmap(addr=0x%x)", addr); + sys_vm.Warning("sys_vm_unmap(addr=0x%x)", addr); // Simply free the memory to unmap. if(!Memory.Free(addr)) return CELL_EINVAL; @@ -74,7 +75,7 @@ s32 sys_vm_unmap(u32 addr) s32 sys_vm_append_memory(u32 addr, u32 size) { - sc_vm.Warning("sys_vm_append_memory(addr=0x%x,size=0x%x)", addr, size); + sys_vm.Warning("sys_vm_append_memory(addr=0x%x,size=0x%x)", addr, size); // Check address and size. if((current_ct->addr != addr) || (size <= 0)) @@ -96,7 +97,7 @@ s32 sys_vm_append_memory(u32 addr, u32 size) s32 sys_vm_return_memory(u32 addr, u32 size) { - sc_vm.Warning("sys_vm_return_memory(addr=0x%x,size=0x%x)", addr, size); + sys_vm.Warning("sys_vm_return_memory(addr=0x%x,size=0x%x)", addr, size); // Check address and size. if((current_ct->addr != addr) || (size <= 0)) @@ -118,7 +119,7 @@ s32 sys_vm_return_memory(u32 addr, u32 size) s32 sys_vm_lock(u32 addr, u32 size) { - sc_vm.Warning("sys_vm_lock(addr=0x%x,size=0x%x)", addr, size); + sys_vm.Warning("sys_vm_lock(addr=0x%x,size=0x%x)", addr, size); // Check address and size. if((current_ct->addr != addr) || (current_ct->size < size) || (size <= 0)) @@ -140,7 +141,7 @@ s32 sys_vm_lock(u32 addr, u32 size) s32 sys_vm_unlock(u32 addr, u32 size) { - sc_vm.Warning("sys_vm_unlock(addr=0x%x,size=0x%x)", addr, size); + sys_vm.Warning("sys_vm_unlock(addr=0x%x,size=0x%x)", addr, size); // Check address and size. if((current_ct->addr != addr) || (current_ct->size < size) || (size <= 0)) @@ -155,7 +156,7 @@ s32 sys_vm_unlock(u32 addr, u32 size) s32 sys_vm_touch(u32 addr, u32 size) { - sc_vm.Todo("sys_vm_touch(addr=0x%x,size=0x%x)", addr, size); + sys_vm.Todo("sys_vm_touch(addr=0x%x,size=0x%x)", addr, size); // Check address and size. if((current_ct->addr != addr) || (current_ct->size < size) || (size <= 0)) @@ -172,7 +173,7 @@ s32 sys_vm_touch(u32 addr, u32 size) s32 sys_vm_flush(u32 addr, u32 size) { - sc_vm.Todo("sys_vm_flush(addr=0x%x,size=0x%x)", addr, size); + sys_vm.Todo("sys_vm_flush(addr=0x%x,size=0x%x)", addr, size); // Check address and size. if((current_ct->addr != addr) || (current_ct->size < size) || (size <= 0)) @@ -189,7 +190,7 @@ s32 sys_vm_flush(u32 addr, u32 size) s32 sys_vm_invalidate(u32 addr, u32 size) { - sc_vm.Todo("sys_vm_invalidate(addr=0x%x,size=0x%x)", addr, size); + sys_vm.Todo("sys_vm_invalidate(addr=0x%x,size=0x%x)", addr, size); // Check address and size. if((current_ct->addr != addr) || (current_ct->size < size) || (size <= 0)) @@ -206,7 +207,7 @@ s32 sys_vm_invalidate(u32 addr, u32 size) s32 sys_vm_store(u32 addr, u32 size) { - sc_vm.Todo("sys_vm_store(addr=0x%x,size=0x%x)", addr, size); + sys_vm.Todo("sys_vm_store(addr=0x%x,size=0x%x)", addr, size); // Check address and size. if((current_ct->addr != addr) || (current_ct->size < size) || (size <= 0)) @@ -223,7 +224,7 @@ s32 sys_vm_store(u32 addr, u32 size) s32 sys_vm_sync(u32 addr, u32 size) { - sc_vm.Todo("sys_vm_sync(addr=0x%x,size=0x%x)", addr, size); + sys_vm.Todo("sys_vm_sync(addr=0x%x,size=0x%x)", addr, size); // Check address and size. if((current_ct->addr != addr) || (current_ct->size < size) || (size <= 0)) @@ -239,7 +240,7 @@ s32 sys_vm_sync(u32 addr, u32 size) s32 sys_vm_test(u32 addr, u32 size, u32 result_addr) { - sc_vm.Todo("sys_vm_test(addr=0x%x,size=0x%x,result_addr=0x%x)", addr, size, result_addr); + sys_vm.Todo("sys_vm_test(addr=0x%x,size=0x%x,result_addr=0x%x)", addr, size, result_addr); // Check address and size. if((current_ct->addr != addr) || (current_ct->size < size) || (size <= 0)) @@ -258,7 +259,7 @@ s32 sys_vm_test(u32 addr, u32 size, u32 result_addr) s32 sys_vm_get_statistics(u32 addr, u32 stat_addr) { - sc_vm.Todo("sys_vm_get_statistics(addr=0x%x,stat_addr=0x%x)", addr, stat_addr); + sys_vm.Todo("sys_vm_get_statistics(addr=0x%x,stat_addr=0x%x)", addr, stat_addr); // Check address. if(current_ct->addr != addr) diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index f32697a716..07693354a5 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -3,8 +3,9 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/SysCalls/SC_FUNC.h" +#include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/Modules.h" +#include "Emu/SysCalls/Static.h" #include "Emu/Cell/PPUInstrTable.h" #include "Emu/SysCalls/ModuleManager.h" #include "ELF64.h" diff --git a/rpcs3/Loader/SELF.cpp b/rpcs3/Loader/SELF.cpp index b614267bb2..2357d6e2d7 100644 --- a/rpcs3/Loader/SELF.cpp +++ b/rpcs3/Loader/SELF.cpp @@ -3,6 +3,56 @@ #include "SELF.h" #include "ELF64.h" +void SceHeader::Load(vfsStream& f) +{ + se_magic = Read32(f); + se_hver = Read32(f); + se_flags = Read16(f); + se_type = Read16(f); + se_meta = Read32(f); + se_hsize = Read64(f); + se_esize = Read64(f); +} + +void SceHeader::Show() +{ + LOG_NOTICE(LOADER, "Magic: %08x", se_magic); + LOG_NOTICE(LOADER, "Class: %s", "SELF"); + LOG_NOTICE(LOADER, "hver: 0x%08x", se_hver); + LOG_NOTICE(LOADER, "flags: 0x%04x", se_flags); + LOG_NOTICE(LOADER, "type: 0x%04x", se_type); + LOG_NOTICE(LOADER, "meta: 0x%08x", se_meta); + LOG_NOTICE(LOADER, "hsize: 0x%llx", se_hsize); + LOG_NOTICE(LOADER, "esize: 0x%llx", se_esize); +} + +void SelfHeader::Load(vfsStream& f) +{ + se_htype = Read64(f); + se_appinfooff = Read64(f); + se_elfoff = Read64(f); + se_phdroff = Read64(f); + se_shdroff = Read64(f); + se_secinfoff = Read64(f); + se_sceveroff = Read64(f); + se_controloff = Read64(f); + se_controlsize = Read64(f); + pad = Read64(f); +} + +void SelfHeader::Show() +{ + LOG_NOTICE(LOADER, "header type: 0x%llx", se_htype); + LOG_NOTICE(LOADER, "app info offset: 0x%llx", se_appinfooff); + LOG_NOTICE(LOADER, "elf offset: 0x%llx", se_elfoff); + LOG_NOTICE(LOADER, "program header offset: 0x%llx", se_phdroff); + LOG_NOTICE(LOADER, "section header offset: 0x%llx", se_shdroff); + LOG_NOTICE(LOADER, "section info offset: 0x%llx", se_secinfoff); + LOG_NOTICE(LOADER, "sce version offset: 0x%llx", se_sceveroff); + LOG_NOTICE(LOADER, "control info offset: 0x%llx", se_controloff); + LOG_NOTICE(LOADER, "control info size: 0x%llx", se_controlsize); +} + SELFLoader::SELFLoader(vfsStream& f) : self_f(f) , LoaderBase() diff --git a/rpcs3/Loader/SELF.h b/rpcs3/Loader/SELF.h index 6058456026..8c3cb70d51 100644 --- a/rpcs3/Loader/SELF.h +++ b/rpcs3/Loader/SELF.h @@ -11,28 +11,9 @@ struct SceHeader u64 se_hsize; u64 se_esize; - void Load(vfsStream& f) - { - se_magic = Read32(f); - se_hver = Read32(f); - se_flags = Read16(f); - se_type = Read16(f); - se_meta = Read32(f); - se_hsize = Read64(f); - se_esize = Read64(f); - } + void Load(vfsStream& f); - void Show() - { - LOG_NOTICE(LOADER, "Magic: %08x", se_magic); - LOG_NOTICE(LOADER, "Class: %s", "SELF"); - LOG_NOTICE(LOADER, "hver: 0x%08x", se_hver); - LOG_NOTICE(LOADER, "flags: 0x%04x", se_flags); - LOG_NOTICE(LOADER, "type: 0x%04x", se_type); - LOG_NOTICE(LOADER, "meta: 0x%08x", se_meta); - LOG_NOTICE(LOADER, "hsize: 0x%llx", se_hsize); - LOG_NOTICE(LOADER, "esize: 0x%llx", se_esize); - } + void Show(); bool CheckMagic() const { return se_magic == 0x53434500; } }; @@ -50,32 +31,9 @@ struct SelfHeader u64 se_controlsize; u64 pad; - void Load(vfsStream& f) - { - se_htype = Read64(f); - se_appinfooff = Read64(f); - se_elfoff = Read64(f); - se_phdroff = Read64(f); - se_shdroff = Read64(f); - se_secinfoff = Read64(f); - se_sceveroff = Read64(f); - se_controloff = Read64(f); - se_controlsize = Read64(f); - pad = Read64(f); - } + void Load(vfsStream& f); - void Show() - { - LOG_NOTICE(LOADER, "header type: 0x%llx", se_htype); - LOG_NOTICE(LOADER, "app info offset: 0x%llx", se_appinfooff); - LOG_NOTICE(LOADER, "elf offset: 0x%llx", se_elfoff); - LOG_NOTICE(LOADER, "program header offset: 0x%llx", se_phdroff); - LOG_NOTICE(LOADER, "section header offset: 0x%llx", se_shdroff); - LOG_NOTICE(LOADER, "section info offset: 0x%llx", se_secinfoff); - LOG_NOTICE(LOADER, "sce version offset: 0x%llx", se_sceveroff); - LOG_NOTICE(LOADER, "control info offset: 0x%llx", se_controloff); - LOG_NOTICE(LOADER, "control info size: 0x%llx", se_controlsize); - } + void Show(); }; class SELFLoader : public LoaderBase