mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-03 08:40:44 +00:00
added more proper and faster hex logging conversion
This commit is contained in:
parent
a135981fdd
commit
ba8b614afc
@ -42,10 +42,10 @@ int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u
|
||||
}
|
||||
auto memtype = magic_enum::enum_cast<MemoryTypes>(memoryType);
|
||||
|
||||
LOG_INFO_IF(true, "search_start = {:#018x}\n", searchStart);
|
||||
LOG_INFO_IF(true, "search_end = {:#018x}\n", searchEnd);
|
||||
LOG_INFO_IF(true, "len = {:#018x}\n", len);
|
||||
LOG_INFO_IF(true, "alignment = {:#018x}\n", alignment);
|
||||
LOG_INFO_IF(true, "search_start = {}\n", log_hex_full(searchStart));
|
||||
LOG_INFO_IF(true, "search_end = {}\n", log_hex_full(searchEnd));
|
||||
LOG_INFO_IF(true, "len = {}\n", log_hex_full(len));
|
||||
LOG_INFO_IF(true, "alignment = {}\n", log_hex_full(alignment));
|
||||
LOG_INFO_IF(true, "memory_type = {}\n", magic_enum::enum_name(memtype.value()));
|
||||
|
||||
u64 physical_addr = 0;
|
||||
@ -55,7 +55,14 @@ int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u
|
||||
return SCE_KERNEL_ERROR_EAGAIN;
|
||||
}
|
||||
*physAddrOut = static_cast<s64>(physical_addr);
|
||||
LOG_INFO_IF(true, "physAddrOut = {:#018x}\n", physical_addr);
|
||||
LOG_INFO_IF(true, "physAddrOut = {}\n", log_hex_full(physical_addr));
|
||||
return SCE_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int flags, s64 directMemoryStart, u64 alignment)
|
||||
{
|
||||
auto* physical_memory = Singleton<HLE::Kernel::Objects::PhysicalMemory>::Instance();
|
||||
BREAKPOINT();
|
||||
return SCE_OK;
|
||||
}
|
||||
|
||||
|
@ -18,5 +18,5 @@ namespace HLE::Libs::LibKernel::MemoryManagement {
|
||||
|
||||
u64 PS4_SYSV_ABI sceKernelGetDirectMemorySize();
|
||||
int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u64 len, u64 alignment, int memoryType, s64* physAddrOut);
|
||||
|
||||
int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int flags, s64 directMemoryStart, u64 alignment);
|
||||
}; // namespace HLE::Libs::LibKernel::MemoryManagement
|
@ -11,11 +11,6 @@ namespace HLE::Libs::LibKernel {
|
||||
|
||||
static u64 g_stack_chk_guard = 0xDEADBEEF54321ABC; //dummy return
|
||||
|
||||
int32_t PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, size_t len, int prot, int flags, off_t directMemoryStart, size_t alignment) {
|
||||
auto* physical_memory = Singleton<HLE::Kernel::Objects::PhysicalMemory>::Instance();
|
||||
BREAKPOINT();
|
||||
return 0;
|
||||
}
|
||||
int32_t PS4_SYSV_ABI sceKernelReleaseDirectMemory(off_t start, size_t len) {
|
||||
BREAKPOINT();
|
||||
return 0;
|
||||
@ -45,9 +40,9 @@ namespace HLE::Libs::LibKernel {
|
||||
//obj
|
||||
LIB_OBJ("f7uOxY9mM1U", "libkernel", 1, "libkernel", 1, 1, &HLE::Libs::LibKernel::g_stack_chk_guard);
|
||||
//memory
|
||||
LIB_FUNCTION("rTXw65xmLIA", "libkernel", 1, "libkernel", 1, 1, HLE::Libs::LibKernel::MemoryManagement::sceKernelAllocateDirectMemory);
|
||||
LIB_FUNCTION("pO96TwzOm5E", "libkernel", 1, "libkernel", 1, 1, HLE::Libs::LibKernel::MemoryManagement::sceKernelGetDirectMemorySize);
|
||||
LIB_FUNCTION("L-Q3LEjIbgA", "libkernel", 1, "libkernel", 1, 1, sceKernelMapDirectMemory);
|
||||
LIB_FUNCTION("rTXw65xmLIA", "libkernel", 1, "libkernel", 1, 1, MemoryManagement::sceKernelAllocateDirectMemory);
|
||||
LIB_FUNCTION("pO96TwzOm5E", "libkernel", 1, "libkernel", 1, 1, MemoryManagement::sceKernelGetDirectMemorySize);
|
||||
LIB_FUNCTION("L-Q3LEjIbgA", "libkernel", 1, "libkernel", 1, 1, MemoryManagement::sceKernelMapDirectMemory);
|
||||
LIB_FUNCTION("MBuItvba6z8", "libkernel", 1, "libkernel", 1, 1, sceKernelReleaseDirectMemory);
|
||||
//equeue
|
||||
LIB_FUNCTION("D0OdFMjp46I", "libkernel", 1, "libkernel", 1, 1, sceKernelCreateEqueue);
|
||||
|
@ -6,7 +6,7 @@ void LibKernel_Register(SymbolsResolver* sym);
|
||||
|
||||
// functions
|
||||
int PS4_SYSV_ABI sceKernelCreateEqueue(/* SceKernelEqueue* eq*/ int eq, const char* name);
|
||||
int32_t PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, size_t len, int prot, int flags, off_t directMemoryStart, size_t alignment);
|
||||
|
||||
int32_t PS4_SYSV_ABI sceKernelReleaseDirectMemory(off_t start, size_t len);
|
||||
int PS4_SYSV_ABI sceKernelIsNeoMode();
|
||||
int PS4_SYSV_ABI sceKernelWaitEqueue(/*SceKernelEqueue eq, SceKernelEvent* ev,*/ int num, int* out /*, SceKernelUseconds* timo*/);
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
|
||||
namespace logging {
|
||||
|
||||
#define LOG_TRACE SPDLOG_TRACE
|
||||
@ -13,23 +12,59 @@ namespace logging {
|
||||
#define LOG_CRITICAL SPDLOG_CRITICAL
|
||||
|
||||
#define LOG_TRACE_IF(flag, ...) \
|
||||
if (flag) \
|
||||
LOG_TRACE(__VA_ARGS__)
|
||||
if (flag) LOG_TRACE(__VA_ARGS__)
|
||||
#define LOG_DEBUG_IF(flag, ...) \
|
||||
if (flag) \
|
||||
LOG_DEBUG(__VA_ARGS__)
|
||||
if (flag) LOG_DEBUG(__VA_ARGS__)
|
||||
#define LOG_INFO_IF(flag, ...) \
|
||||
if (flag) \
|
||||
LOG_INFO(__VA_ARGS__)
|
||||
if (flag) LOG_INFO(__VA_ARGS__)
|
||||
#define LOG_WARN_IF(flag, ...) \
|
||||
if (flag) \
|
||||
LOG_WARN(__VA_ARGS__)
|
||||
if (flag) LOG_WARN(__VA_ARGS__)
|
||||
#define LOG_ERROR_IF(flag, ...) \
|
||||
if (flag) \
|
||||
LOG_ERROR(__VA_ARGS__)
|
||||
if (flag) LOG_ERROR(__VA_ARGS__)
|
||||
#define LOG_CRITICAL_IF(flag, ...) \
|
||||
if (flag) \
|
||||
LOG_CRITICAL(__VA_ARGS__)
|
||||
if (flag) LOG_CRITICAL(__VA_ARGS__)
|
||||
|
||||
int init(bool use_stdout);
|
||||
int init(bool use_stdout);
|
||||
} // namespace logging
|
||||
|
||||
// copyright vita3k emu https://github.com/Vita3K/Vita3K/blob/master/vita3k/util/include/util/log.h
|
||||
/*
|
||||
returns: A string with the input number formatted in hexadecimal
|
||||
Examples:
|
||||
* `12` returns: `"0xC"`
|
||||
* `1337` returns: `"0x539"`
|
||||
* `72742069` returns: `"0x455F4B5"`
|
||||
*/
|
||||
template <typename T>
|
||||
std::string log_hex(T val) {
|
||||
using unsigned_type = typename std::make_unsigned<T>::type;
|
||||
std::stringstream ss;
|
||||
ss << "0x";
|
||||
ss << std::hex << static_cast<unsigned_type>(val);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
/*
|
||||
returns: A string with the input number formatted in hexadecimal with padding of the inputted type size
|
||||
Examples:
|
||||
* `uint8_t 5` returns: `"0x05"`
|
||||
* `uint8_t 15` returns: `"0x0F"`
|
||||
* `uint8_t 255` returns: `"0xFF"`
|
||||
|
||||
* `uint16_t 15` returns: `"0x000F"`
|
||||
* `uint16_t 1337` returns: `"0x0539"`
|
||||
* `uint16_t 65535` returns: `"0xFFFF"`
|
||||
|
||||
|
||||
* `uint32_t 15` returns: `"0x0000000F"`
|
||||
* `uint32_t 1337` returns: `"0x00000539"`
|
||||
* `uint32_t 65535` returns: `"0x0000FFFF"`
|
||||
* `uint32_t 134217728` returns: `"0x08000000"`
|
||||
*/
|
||||
template <typename T>
|
||||
std::string log_hex_full(T val) {
|
||||
std::stringstream ss;
|
||||
ss << "0x";
|
||||
ss << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex << val;
|
||||
return ss.str();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user