citra-emu
/
citra
Archived
1
0
Fork 0

Merge pull request #3876 from NarcolepticK/kernel-migrate-logging

hle/kernel: Migrate logging macros
This commit is contained in:
Weiyi Wang 2018-06-24 01:34:22 +03:00 committed by GitHub
commit 689977bbf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 132 additions and 126 deletions

View File

@ -147,6 +147,9 @@ void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsig
LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Critical, __VA_ARGS__) LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Critical, __VA_ARGS__)
// Define the fmt lib macros // Define the fmt lib macros
#define NGLOG_GENERIC(log_class, log_level, ...) \
::Log::FmtLogMessage(log_class, log_level, __FILE__, __LINE__, __func__, __VA_ARGS__)
#ifdef _DEBUG #ifdef _DEBUG
#define NGLOG_TRACE(log_class, ...) \ #define NGLOG_TRACE(log_class, ...) \
::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Trace, __FILE__, __LINE__, \ ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Trace, __FILE__, __LINE__, \

View File

@ -135,7 +135,7 @@ ResultCode AddressArbiter::ArbitrateAddress(SharedPtr<Thread> thread, Arbitratio
} }
default: default:
LOG_ERROR(Kernel, "unknown type=%d", static_cast<u32>(type)); NGLOG_ERROR(Kernel, "unknown type={}", static_cast<u32>(type));
return ERR_INVALID_ENUM_VALUE_FND; return ERR_INVALID_ENUM_VALUE_FND;
} }

View File

@ -25,7 +25,7 @@ ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) {
u16 slot = next_free_slot; u16 slot = next_free_slot;
if (slot >= generations.size()) { if (slot >= generations.size()) {
LOG_ERROR(Kernel, "Unable to allocate Handle, too many slots in use."); NGLOG_ERROR(Kernel, "Unable to allocate Handle, too many slots in use.");
return ERR_OUT_OF_HANDLES; return ERR_OUT_OF_HANDLES;
} }
next_free_slot = generations[slot]; next_free_slot = generations[slot];
@ -47,7 +47,7 @@ ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) {
ResultVal<Handle> HandleTable::Duplicate(Handle handle) { ResultVal<Handle> HandleTable::Duplicate(Handle handle) {
SharedPtr<Object> object = GetGeneric(handle); SharedPtr<Object> object = GetGeneric(handle);
if (object == nullptr) { if (object == nullptr) {
LOG_ERROR(Kernel, "Tried to duplicate invalid handle: %08X", handle); NGLOG_ERROR(Kernel, "Tried to duplicate invalid handle: {:08X}", handle);
return ERR_INVALID_HANDLE; return ERR_INVALID_HANDLE;
} }
return Create(std::move(object)); return Create(std::move(object));

View File

@ -115,8 +115,8 @@ void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mappin
VAddr mapping_limit = mapping.address + mapping.size; VAddr mapping_limit = mapping.address + mapping.size;
if (mapping_limit < mapping.address) { if (mapping_limit < mapping.address) {
LOG_CRITICAL(Loader, "Mapping size overflowed: address=0x%08" PRIX32 " size=0x%" PRIX32, NGLOG_CRITICAL(Loader, "Mapping size overflowed: address=0x{:08X} size=0x{:X}",
mapping.address, mapping.size); mapping.address, mapping.size);
return; return;
} }
@ -126,17 +126,17 @@ void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mappin
mapping_limit <= area.vaddr_base + area.size; mapping_limit <= area.vaddr_base + area.size;
}); });
if (area == std::end(memory_areas)) { if (area == std::end(memory_areas)) {
LOG_ERROR(Loader, NGLOG_ERROR(Loader,
"Unhandled special mapping: address=0x%08" PRIX32 " size=0x%" PRIX32 "Unhandled special mapping: address=0x{:08X} size=0x{:X}"
" read_only=%d unk_flag=%d", " read_only={} unk_flag={}",
mapping.address, mapping.size, mapping.read_only, mapping.unk_flag); mapping.address, mapping.size, mapping.read_only, mapping.unk_flag);
return; return;
} }
u32 offset_into_region = mapping.address - area->vaddr_base; u32 offset_into_region = mapping.address - area->vaddr_base;
if (area->paddr_base == IO_AREA_PADDR) { if (area->paddr_base == IO_AREA_PADDR) {
LOG_ERROR(Loader, "MMIO mappings are not supported yet. phys_addr=0x%08" PRIX32, NGLOG_ERROR(Loader, "MMIO mappings are not supported yet. phys_addr=0x{:08X}",
area->paddr_base + offset_into_region); area->paddr_base + offset_into_region);
return; return;
} }

View File

@ -63,9 +63,9 @@ ResultCode Mutex::Release(Thread* thread) {
// We can only release the mutex if it's held by the calling thread. // We can only release the mutex if it's held by the calling thread.
if (thread != holding_thread) { if (thread != holding_thread) {
if (holding_thread) { if (holding_thread) {
LOG_ERROR( NGLOG_ERROR(
Kernel, Kernel,
"Tried to release a mutex (owned by thread id %u) from a different thread id %u", "Tried to release a mutex (owned by thread id {}) from a different thread id {}",
holding_thread->thread_id, thread->thread_id); holding_thread->thread_id, thread->thread_id);
} }
return ResultCode(ErrCodes::WrongLockingThread, ErrorModule::Kernel, return ResultCode(ErrCodes::WrongLockingThread, ErrorModule::Kernel,

View File

@ -56,7 +56,7 @@ void Process::ParseKernelCaps(const u32* kernel_caps, size_t len) {
continue; continue;
} else if ((type & 0xF00) == 0xE00) { // 0x0FFF } else if ((type & 0xF00) == 0xE00) { // 0x0FFF
// Allowed interrupts list // Allowed interrupts list
LOG_WARNING(Loader, "ExHeader allowed interrupts list ignored"); NGLOG_WARNING(Loader, "ExHeader allowed interrupts list ignored");
} else if ((type & 0xF80) == 0xF00) { // 0x07FF } else if ((type & 0xF80) == 0xF00) { // 0x07FF
// Allowed syscalls mask // Allowed syscalls mask
unsigned int index = ((descriptor >> 24) & 7) * 24; unsigned int index = ((descriptor >> 24) & 7) * 24;
@ -76,7 +76,7 @@ void Process::ParseKernelCaps(const u32* kernel_caps, size_t len) {
} else if ((type & 0xFFE) == 0xFF8) { // 0x001F } else if ((type & 0xFFE) == 0xFF8) { // 0x001F
// Mapped memory range // Mapped memory range
if (i + 1 >= len || ((kernel_caps[i + 1] >> 20) & 0xFFE) != 0xFF8) { if (i + 1 >= len || ((kernel_caps[i + 1] >> 20) & 0xFFE) != 0xFF8) {
LOG_WARNING(Loader, "Incomplete exheader memory range descriptor ignored."); NGLOG_WARNING(Loader, "Incomplete exheader memory range descriptor ignored.");
continue; continue;
} }
u32 end_desc = kernel_caps[i + 1]; u32 end_desc = kernel_caps[i + 1];
@ -111,9 +111,9 @@ void Process::ParseKernelCaps(const u32* kernel_caps, size_t len) {
int minor = kernel_version & 0xFF; int minor = kernel_version & 0xFF;
int major = (kernel_version >> 8) & 0xFF; int major = (kernel_version >> 8) & 0xFF;
LOG_INFO(Loader, "ExHeader kernel version: %d.%d", major, minor); NGLOG_INFO(Loader, "ExHeader kernel version: {}.{}", major, minor);
} else { } else {
LOG_ERROR(Loader, "Unhandled kernel caps descriptor: 0x%08X", descriptor); NGLOG_ERROR(Loader, "Unhandled kernel caps descriptor: 0x{:08X}", descriptor);
} }
} }
} }

View File

@ -29,7 +29,7 @@ SharedPtr<ResourceLimit> ResourceLimit::GetForCategory(ResourceLimitCategory cat
case ResourceLimitCategory::OTHER: case ResourceLimitCategory::OTHER:
return resource_limits[static_cast<u8>(category)]; return resource_limits[static_cast<u8>(category)];
default: default:
LOG_CRITICAL(Kernel, "Unknown resource limit category"); NGLOG_CRITICAL(Kernel, "Unknown resource limit category");
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -55,7 +55,7 @@ s32 ResourceLimit::GetCurrentResourceValue(u32 resource) const {
case CPU_TIME: case CPU_TIME:
return current_cpu_time; return current_cpu_time;
default: default:
LOG_ERROR(Kernel, "Unknown resource type=%08X", resource); NGLOG_ERROR(Kernel, "Unknown resource type={:08X}", resource);
UNIMPLEMENTED(); UNIMPLEMENTED();
return 0; return 0;
} }
@ -84,7 +84,7 @@ u32 ResourceLimit::GetMaxResourceValue(u32 resource) const {
case CPU_TIME: case CPU_TIME:
return max_cpu_time; return max_cpu_time;
default: default:
LOG_ERROR(Kernel, "Unknown resource type=%08X", resource); NGLOG_ERROR(Kernel, "Unknown resource type={:08X}", resource);
UNIMPLEMENTED(); UNIMPLEMENTED();
return 0; return 0;
} }

View File

@ -106,23 +106,23 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
// Error out if the requested permissions don't match what the creator process allows. // Error out if the requested permissions don't match what the creator process allows.
if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) { if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) {
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match", NGLOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, permissions don't match",
GetObjectId(), address, name.c_str()); GetObjectId(), address, name);
return ERR_INVALID_COMBINATION; return ERR_INVALID_COMBINATION;
} }
// Heap-backed memory blocks can not be mapped with other_permissions = DontCare // Heap-backed memory blocks can not be mapped with other_permissions = DontCare
if (base_address != 0 && other_permissions == MemoryPermission::DontCare) { if (base_address != 0 && other_permissions == MemoryPermission::DontCare) {
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match", NGLOG_ERROR(Kernel, "cannot map id={}, address=0x{08X} name={}, permissions don't match",
GetObjectId(), address, name.c_str()); GetObjectId(), address, name);
return ERR_INVALID_COMBINATION; return ERR_INVALID_COMBINATION;
} }
// Error out if the provided permissions are not compatible with what the creator process needs. // Error out if the provided permissions are not compatible with what the creator process needs.
if (other_permissions != MemoryPermission::DontCare && if (other_permissions != MemoryPermission::DontCare &&
static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) { static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) {
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match", NGLOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, permissions don't match",
GetObjectId(), address, name.c_str()); GetObjectId(), address, name);
return ERR_WRONG_PERMISSION; return ERR_WRONG_PERMISSION;
} }
@ -137,8 +137,8 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
if (address != 0) { if (address != 0) {
if (address < Memory::HEAP_VADDR || address + size >= Memory::SHARED_MEMORY_VADDR_END) { if (address < Memory::HEAP_VADDR || address + size >= Memory::SHARED_MEMORY_VADDR_END) {
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, invalid address", NGLOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, invalid address",
GetObjectId(), address, name.c_str()); GetObjectId(), address, name);
return ERR_INVALID_ADDRESS; return ERR_INVALID_ADDRESS;
} }
} }
@ -154,10 +154,10 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
auto result = target_process->vm_manager.MapMemoryBlock( auto result = target_process->vm_manager.MapMemoryBlock(
target_address, backing_block, backing_block_offset, size, MemoryState::Shared); target_address, backing_block, backing_block_offset, size, MemoryState::Shared);
if (result.Failed()) { if (result.Failed()) {
LOG_ERROR( NGLOG_ERROR(
Kernel, Kernel,
"cannot map id=%u, target_address=0x%08X name=%s, error mapping to virtual memory", "cannot map id={}, target_address=0x{:08X} name={}, error mapping to virtual memory",
GetObjectId(), target_address, name.c_str()); GetObjectId(), target_address, name);
return result.Code(); return result.Code();
} }

View File

@ -58,9 +58,10 @@ enum ControlMemoryOperation {
/// Map application or GSP heap memory /// Map application or GSP heap memory
static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size,
u32 permissions) { u32 permissions) {
LOG_DEBUG(Kernel_SVC, NGLOG_DEBUG(Kernel_SVC,
"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=0x%X, permissions=0x%08X", "called operation=0x{:08X}, addr0=0x{:08X}, addr1=0x{:08X}, "
operation, addr0, addr1, size, permissions); "size=0x{:X}, permissions=0x{:08X}",
operation, addr0, addr1, size, permissions);
if ((addr0 & Memory::PAGE_MASK) != 0 || (addr1 & Memory::PAGE_MASK) != 0) { if ((addr0 & Memory::PAGE_MASK) != 0 || (addr1 & Memory::PAGE_MASK) != 0) {
return ERR_MISALIGNED_ADDRESS; return ERR_MISALIGNED_ADDRESS;
@ -73,8 +74,8 @@ static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 add
operation &= ~MEMOP_REGION_MASK; operation &= ~MEMOP_REGION_MASK;
if (region != 0) { if (region != 0) {
LOG_WARNING(Kernel_SVC, "ControlMemory with specified region not supported, region=%X", NGLOG_WARNING(Kernel_SVC, "ControlMemory with specified region not supported, region={:X}",
region); region);
} }
if ((permissions & (u32)MemoryPermission::ReadWrite) != permissions) { if ((permissions & (u32)MemoryPermission::ReadWrite) != permissions) {
@ -134,7 +135,7 @@ static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 add
} }
default: default:
LOG_ERROR(Kernel_SVC, "unknown operation=0x%08X", operation); NGLOG_ERROR(Kernel_SVC, "unknown operation=0x{:08X}", operation);
return ERR_INVALID_COMBINATION; return ERR_INVALID_COMBINATION;
} }
@ -144,7 +145,7 @@ static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 add
} }
static void ExitProcess() { static void ExitProcess() {
LOG_INFO(Kernel_SVC, "Process %u exiting", g_current_process->process_id); NGLOG_INFO(Kernel_SVC, "Process {} exiting", g_current_process->process_id);
ASSERT_MSG(g_current_process->status == ProcessStatus::Running, "Process has already exited"); ASSERT_MSG(g_current_process->status == ProcessStatus::Running, "Process has already exited");
@ -175,9 +176,10 @@ static void ExitProcess() {
/// Maps a memory block to specified address /// Maps a memory block to specified address
static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) { static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) {
LOG_TRACE(Kernel_SVC, NGLOG_TRACE(Kernel_SVC,
"called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", "called memblock=0x{:08X}, addr=0x{:08X}, mypermissions=0x{:08X}, "
handle, addr, permissions, other_permissions); "otherpermission={}",
handle, addr, permissions, other_permissions);
SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(handle); SharedPtr<SharedMemory> shared_memory = g_handle_table.Get<SharedMemory>(handle);
if (shared_memory == nullptr) if (shared_memory == nullptr)
@ -196,14 +198,14 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o
return shared_memory->Map(g_current_process.get(), addr, permissions_type, return shared_memory->Map(g_current_process.get(), addr, permissions_type,
static_cast<MemoryPermission>(other_permissions)); static_cast<MemoryPermission>(other_permissions));
default: default:
LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions); NGLOG_ERROR(Kernel_SVC, "unknown permissions=0x{:08X}", permissions);
} }
return ERR_INVALID_COMBINATION; return ERR_INVALID_COMBINATION;
} }
static ResultCode UnmapMemoryBlock(Handle handle, u32 addr) { static ResultCode UnmapMemoryBlock(Handle handle, u32 addr) {
LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X", handle, addr); NGLOG_TRACE(Kernel_SVC, "called memblock=0x{:08X}, addr=0x{:08X}", handle, addr);
// TODO(Subv): Return E0A01BF5 if the address is not in the application's heap // TODO(Subv): Return E0A01BF5 if the address is not in the application's heap
@ -225,11 +227,11 @@ static ResultCode ConnectToPort(Handle* out_handle, VAddr port_name_address) {
if (port_name.size() > PortNameMaxLength) if (port_name.size() > PortNameMaxLength)
return ERR_PORT_NAME_TOO_LONG; return ERR_PORT_NAME_TOO_LONG;
LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name.c_str()); NGLOG_TRACE(Kernel_SVC, "called port_name={}", port_name);
auto it = Service::g_kernel_named_ports.find(port_name); auto it = Service::g_kernel_named_ports.find(port_name);
if (it == Service::g_kernel_named_ports.end()) { if (it == Service::g_kernel_named_ports.end()) {
LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name.c_str()); NGLOG_WARNING(Kernel_SVC, "tried to connect to unknown port: {}", port_name);
return ERR_NOT_FOUND; return ERR_NOT_FOUND;
} }
@ -250,7 +252,7 @@ static ResultCode SendSyncRequest(Handle handle) {
return ERR_INVALID_HANDLE; return ERR_INVALID_HANDLE;
} }
LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s)", handle, session->GetName().c_str()); NGLOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName());
Core::System::GetInstance().PrepareReschedule(); Core::System::GetInstance().PrepareReschedule();
@ -259,7 +261,7 @@ static ResultCode SendSyncRequest(Handle handle) {
/// Close a handle /// Close a handle
static ResultCode CloseHandle(Handle handle) { static ResultCode CloseHandle(Handle handle) {
LOG_TRACE(Kernel_SVC, "Closing handle 0x%08X", handle); NGLOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle);
return g_handle_table.Close(handle); return g_handle_table.Close(handle);
} }
@ -271,8 +273,8 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
if (object == nullptr) if (object == nullptr)
return ERR_INVALID_HANDLE; return ERR_INVALID_HANDLE;
LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, NGLOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({}:{}), nanoseconds={}", handle,
object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds); object->GetTypeName(), object->GetName(), nano_seconds);
if (object->ShouldWait(thread)) { if (object->ShouldWait(thread)) {
@ -615,15 +617,16 @@ static ResultCode ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_
static ResultCode CreateAddressArbiter(Handle* out_handle) { static ResultCode CreateAddressArbiter(Handle* out_handle) {
SharedPtr<AddressArbiter> arbiter = AddressArbiter::Create(); SharedPtr<AddressArbiter> arbiter = AddressArbiter::Create();
CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(arbiter))); CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(arbiter)));
LOG_TRACE(Kernel_SVC, "returned handle=0x%08X", *out_handle); NGLOG_TRACE(Kernel_SVC, "returned handle=0x{:08X}", *out_handle);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
/// Arbitrate address /// Arbitrate address
static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 value, static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 value,
s64 nanoseconds) { s64 nanoseconds) {
LOG_TRACE(Kernel_SVC, "called handle=0x%08X, address=0x%08X, type=0x%08X, value=0x%08X", handle, NGLOG_TRACE(Kernel_SVC,
address, type, value); "called handle=0x{:08X}, address=0x{:08X}, type=0x{:08X}, value=0x{:08X}", handle,
address, type, value);
SharedPtr<AddressArbiter> arbiter = g_handle_table.Get<AddressArbiter>(handle); SharedPtr<AddressArbiter> arbiter = g_handle_table.Get<AddressArbiter>(handle);
if (arbiter == nullptr) if (arbiter == nullptr)
@ -639,7 +642,7 @@ static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 val
} }
static void Break(u8 break_reason) { static void Break(u8 break_reason) {
LOG_CRITICAL(Debug_Emulated, "Emulated program broke execution!"); NGLOG_CRITICAL(Debug_Emulated, "Emulated program broke execution!");
std::string reason_str; std::string reason_str;
switch (break_reason) { switch (break_reason) {
case 0: case 0:
@ -655,19 +658,19 @@ static void Break(u8 break_reason) {
reason_str = "UNKNOWN"; reason_str = "UNKNOWN";
break; break;
} }
LOG_CRITICAL(Debug_Emulated, "Break reason: %s", reason_str.c_str()); NGLOG_CRITICAL(Debug_Emulated, "Break reason: {}", reason_str);
} }
/// Used to output a message on a debug hardware unit - does nothing on a retail unit /// Used to output a message on a debug hardware unit - does nothing on a retail unit
static void OutputDebugString(VAddr address, int len) { static void OutputDebugString(VAddr address, int len) {
std::vector<char> string(len); std::string string(len, ' ');
Memory::ReadBlock(address, string.data(), len); Memory::ReadBlock(address, string.data(), len);
LOG_DEBUG(Debug_Emulated, "%.*s", len, string.data()); NGLOG_DEBUG(Debug_Emulated, "{}", string);
} }
/// Get resource limit /// Get resource limit
static ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle) { static ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle) {
LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); NGLOG_TRACE(Kernel_SVC, "called process=0x{:08X}", process_handle);
SharedPtr<Process> process = g_handle_table.Get<Process>(process_handle); SharedPtr<Process> process = g_handle_table.Get<Process>(process_handle);
if (process == nullptr) if (process == nullptr)
@ -681,8 +684,8 @@ static ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle
/// Get resource limit current values /// Get resource limit current values
static ResultCode GetResourceLimitCurrentValues(VAddr values, Handle resource_limit_handle, static ResultCode GetResourceLimitCurrentValues(VAddr values, Handle resource_limit_handle,
VAddr names, u32 name_count) { VAddr names, u32 name_count) {
LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%08X, name_count=%d", NGLOG_TRACE(Kernel_SVC, "called resource_limit={:08X}, names={:08X}, name_count={}",
resource_limit_handle, names, name_count); resource_limit_handle, names, name_count);
SharedPtr<ResourceLimit> resource_limit = SharedPtr<ResourceLimit> resource_limit =
g_handle_table.Get<ResourceLimit>(resource_limit_handle); g_handle_table.Get<ResourceLimit>(resource_limit_handle);
@ -701,8 +704,8 @@ static ResultCode GetResourceLimitCurrentValues(VAddr values, Handle resource_li
/// Get resource limit max values /// Get resource limit max values
static ResultCode GetResourceLimitLimitValues(VAddr values, Handle resource_limit_handle, static ResultCode GetResourceLimitLimitValues(VAddr values, Handle resource_limit_handle,
VAddr names, u32 name_count) { VAddr names, u32 name_count) {
LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%08X, name_count=%d", NGLOG_TRACE(Kernel_SVC, "called resource_limit={:08X}, names={:08X}, name_count={}",
resource_limit_handle, names, name_count); resource_limit_handle, names, name_count);
SharedPtr<ResourceLimit> resource_limit = SharedPtr<ResourceLimit> resource_limit =
g_handle_table.Get<ResourceLimit>(resource_limit_handle); g_handle_table.Get<ResourceLimit>(resource_limit_handle);
@ -742,12 +745,12 @@ static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point
case THREADPROCESSORID_0: case THREADPROCESSORID_0:
break; break;
case THREADPROCESSORID_ALL: case THREADPROCESSORID_ALL:
LOG_INFO(Kernel_SVC, NGLOG_INFO(Kernel_SVC,
"Newly created thread is allowed to be run in any Core, unimplemented."); "Newly created thread is allowed to be run in any Core, unimplemented.");
break; break;
case THREADPROCESSORID_1: case THREADPROCESSORID_1:
LOG_ERROR(Kernel_SVC, NGLOG_ERROR(Kernel_SVC,
"Newly created thread must run in the SysCore (Core1), unimplemented."); "Newly created thread must run in the SysCore (Core1), unimplemented.");
break; break;
default: default:
// TODO(bunnei): Implement support for other processor IDs // TODO(bunnei): Implement support for other processor IDs
@ -766,17 +769,17 @@ static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point
Core::System::GetInstance().PrepareReschedule(); Core::System::GetInstance().PrepareReschedule();
LOG_TRACE(Kernel_SVC, NGLOG_TRACE(Kernel_SVC,
"called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " "called entrypoint=0x{:08X} ({}), arg=0x{:08X}, stacktop=0x{:08X}, "
"threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", "threadpriority=0x{:08X}, processorid=0x{:08X} : created handle=0x{:08X}",
entry_point, name.c_str(), arg, stack_top, priority, processor_id, *out_handle); entry_point, name, arg, stack_top, priority, processor_id, *out_handle);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
/// Called when a thread exits /// Called when a thread exits
static void ExitThread() { static void ExitThread() {
LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::CPU().GetPC()); NGLOG_TRACE(Kernel_SVC, "called, pc=0x{:08X}", Core::CPU().GetPC());
ExitCurrentThread(); ExitCurrentThread();
Core::System::GetInstance().PrepareReschedule(); Core::System::GetInstance().PrepareReschedule();
@ -826,15 +829,15 @@ static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) {
mutex->name = Common::StringFromFormat("mutex-%08x", Core::CPU().GetReg(14)); mutex->name = Common::StringFromFormat("mutex-%08x", Core::CPU().GetReg(14));
CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(mutex))); CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(mutex)));
LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X", NGLOG_TRACE(Kernel_SVC, "called initial_locked={} : created handle=0x{:08X}",
initial_locked ? "true" : "false", *out_handle); initial_locked ? "true" : "false", *out_handle);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
/// Release a mutex /// Release a mutex
static ResultCode ReleaseMutex(Handle handle) { static ResultCode ReleaseMutex(Handle handle) {
LOG_TRACE(Kernel_SVC, "called handle=0x%08X", handle); NGLOG_TRACE(Kernel_SVC, "called handle=0x{:08X}", handle);
SharedPtr<Mutex> mutex = g_handle_table.Get<Mutex>(handle); SharedPtr<Mutex> mutex = g_handle_table.Get<Mutex>(handle);
if (mutex == nullptr) if (mutex == nullptr)
@ -845,7 +848,7 @@ static ResultCode ReleaseMutex(Handle handle) {
/// Get the ID of the specified process /// Get the ID of the specified process
static ResultCode GetProcessId(u32* process_id, Handle process_handle) { static ResultCode GetProcessId(u32* process_id, Handle process_handle) {
LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); NGLOG_TRACE(Kernel_SVC, "called process=0x{:08X}", process_handle);
const SharedPtr<Process> process = g_handle_table.Get<Process>(process_handle); const SharedPtr<Process> process = g_handle_table.Get<Process>(process_handle);
if (process == nullptr) if (process == nullptr)
@ -857,7 +860,7 @@ static ResultCode GetProcessId(u32* process_id, Handle process_handle) {
/// Get the ID of the process that owns the specified thread /// Get the ID of the process that owns the specified thread
static ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle) { static ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle) {
LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); NGLOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle);
const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle); const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(thread_handle);
if (thread == nullptr) if (thread == nullptr)
@ -873,7 +876,7 @@ static ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle) {
/// Get the ID for the specified thread. /// Get the ID for the specified thread.
static ResultCode GetThreadId(u32* thread_id, Handle handle) { static ResultCode GetThreadId(u32* thread_id, Handle handle) {
LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); NGLOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", handle);
const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(handle); const SharedPtr<Thread> thread = g_handle_table.Get<Thread>(handle);
if (thread == nullptr) if (thread == nullptr)
@ -889,14 +892,14 @@ static ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max
semaphore->name = Common::StringFromFormat("semaphore-%08x", Core::CPU().GetReg(14)); semaphore->name = Common::StringFromFormat("semaphore-%08x", Core::CPU().GetReg(14));
CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(semaphore))); CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(semaphore)));
LOG_TRACE(Kernel_SVC, "called initial_count=%d, max_count=%d, created handle=0x%08X", NGLOG_TRACE(Kernel_SVC, "called initial_count={}, max_count={}, created handle=0x{:08X}",
initial_count, max_count, *out_handle); initial_count, max_count, *out_handle);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
/// Releases a certain number of slots in a semaphore /// Releases a certain number of slots in a semaphore
static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) { static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) {
LOG_TRACE(Kernel_SVC, "called release_count=%d, handle=0x%08X", release_count, handle); NGLOG_TRACE(Kernel_SVC, "called release_count={}, handle=0x{:08X}", release_count, handle);
SharedPtr<Semaphore> semaphore = g_handle_table.Get<Semaphore>(handle); SharedPtr<Semaphore> semaphore = g_handle_table.Get<Semaphore>(handle);
if (semaphore == nullptr) if (semaphore == nullptr)
@ -925,7 +928,7 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_inf
memory_info->state = static_cast<u32>(vma->second.meminfo_state); memory_info->state = static_cast<u32>(vma->second.meminfo_state);
page_info->flags = 0; page_info->flags = 0;
LOG_TRACE(Kernel_SVC, "called process=0x%08X addr=0x%08X", process_handle, addr); NGLOG_TRACE(Kernel_SVC, "called process=0x{:08X} addr=0x{:08X}", process_handle, addr);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
@ -940,21 +943,21 @@ static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
evt->name = Common::StringFromFormat("event-%08x", Core::CPU().GetReg(14)); evt->name = Common::StringFromFormat("event-%08x", Core::CPU().GetReg(14));
CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(evt))); CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(evt)));
LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type, NGLOG_TRACE(Kernel_SVC, "called reset_type=0x{:08X} : created handle=0x{:08X}", reset_type,
*out_handle); *out_handle);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
/// Duplicates a kernel handle /// Duplicates a kernel handle
static ResultCode DuplicateHandle(Handle* out, Handle handle) { static ResultCode DuplicateHandle(Handle* out, Handle handle) {
CASCADE_RESULT(*out, g_handle_table.Duplicate(handle)); CASCADE_RESULT(*out, g_handle_table.Duplicate(handle));
LOG_TRACE(Kernel_SVC, "duplicated 0x%08X to 0x%08X", handle, *out); NGLOG_TRACE(Kernel_SVC, "duplicated 0x{:08X} to 0x{:08X}", handle, *out);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
/// Signals an event /// Signals an event
static ResultCode SignalEvent(Handle handle) { static ResultCode SignalEvent(Handle handle) {
LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle); NGLOG_TRACE(Kernel_SVC, "called event=0x{:08X}", handle);
SharedPtr<Event> evt = g_handle_table.Get<Event>(handle); SharedPtr<Event> evt = g_handle_table.Get<Event>(handle);
if (evt == nullptr) if (evt == nullptr)
@ -967,7 +970,7 @@ static ResultCode SignalEvent(Handle handle) {
/// Clears an event /// Clears an event
static ResultCode ClearEvent(Handle handle) { static ResultCode ClearEvent(Handle handle) {
LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle); NGLOG_TRACE(Kernel_SVC, "called event=0x{:08X}", handle);
SharedPtr<Event> evt = g_handle_table.Get<Event>(handle); SharedPtr<Event> evt = g_handle_table.Get<Event>(handle);
if (evt == nullptr) if (evt == nullptr)
@ -983,14 +986,14 @@ static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) {
timer->name = Common::StringFromFormat("timer-%08x", Core::CPU().GetReg(14)); timer->name = Common::StringFromFormat("timer-%08x", Core::CPU().GetReg(14));
CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(timer))); CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(timer)));
LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type, NGLOG_TRACE(Kernel_SVC, "called reset_type=0x{:08X} : created handle=0x{:08X}", reset_type,
*out_handle); *out_handle);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
/// Clears a timer /// Clears a timer
static ResultCode ClearTimer(Handle handle) { static ResultCode ClearTimer(Handle handle) {
LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); NGLOG_TRACE(Kernel_SVC, "called timer=0x{:08X}", handle);
SharedPtr<Timer> timer = g_handle_table.Get<Timer>(handle); SharedPtr<Timer> timer = g_handle_table.Get<Timer>(handle);
if (timer == nullptr) if (timer == nullptr)
@ -1002,7 +1005,7 @@ static ResultCode ClearTimer(Handle handle) {
/// Starts a timer /// Starts a timer
static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) { static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) {
LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); NGLOG_TRACE(Kernel_SVC, "called timer=0x{:08X}", handle);
if (initial < 0 || interval < 0) { if (initial < 0 || interval < 0) {
return ERR_OUT_OF_RANGE_KERNEL; return ERR_OUT_OF_RANGE_KERNEL;
@ -1019,7 +1022,7 @@ static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) {
/// Cancels a timer /// Cancels a timer
static ResultCode CancelTimer(Handle handle) { static ResultCode CancelTimer(Handle handle) {
LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); NGLOG_TRACE(Kernel_SVC, "called timer=0x{:08X}", handle);
SharedPtr<Timer> timer = g_handle_table.Get<Timer>(handle); SharedPtr<Timer> timer = g_handle_table.Get<Timer>(handle);
if (timer == nullptr) if (timer == nullptr)
@ -1032,7 +1035,7 @@ static ResultCode CancelTimer(Handle handle) {
/// Sleep the current thread /// Sleep the current thread
static void SleepThread(s64 nanoseconds) { static void SleepThread(s64 nanoseconds) {
LOG_TRACE(Kernel_SVC, "called nanoseconds=%lld", nanoseconds); NGLOG_TRACE(Kernel_SVC, "called nanoseconds={}", nanoseconds);
// Don't attempt to yield execution if there are no available threads to run, // Don't attempt to yield execution if there are no available threads to run,
// this way we avoid a useless reschedule to the idle thread. // this way we avoid a useless reschedule to the idle thread.
@ -1103,7 +1106,7 @@ static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32
static_cast<MemoryPermission>(other_permission), addr, region); static_cast<MemoryPermission>(other_permission), addr, region);
CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(shared_memory))); CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(shared_memory)));
LOG_WARNING(Kernel_SVC, "called addr=0x%08X", addr); NGLOG_WARNING(Kernel_SVC, "called addr=0x{:08X}", addr);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
@ -1120,7 +1123,7 @@ static ResultCode CreatePort(Handle* server_port, Handle* client_port, VAddr nam
CASCADE_RESULT(*server_port, CASCADE_RESULT(*server_port,
g_handle_table.Create(std::move(std::get<SharedPtr<ServerPort>>(ports)))); g_handle_table.Create(std::move(std::get<SharedPtr<ServerPort>>(ports))));
LOG_TRACE(Kernel_SVC, "called max_sessions=%u", max_sessions); NGLOG_TRACE(Kernel_SVC, "called max_sessions={}", max_sessions);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
@ -1143,7 +1146,7 @@ static ResultCode CreateSession(Handle* server_session, Handle* client_session)
auto& client = std::get<SharedPtr<ClientSession>>(sessions); auto& client = std::get<SharedPtr<ClientSession>>(sessions);
CASCADE_RESULT(*client_session, g_handle_table.Create(std::move(client))); CASCADE_RESULT(*client_session, g_handle_table.Create(std::move(client)));
LOG_TRACE(Kernel_SVC, "called"); NGLOG_TRACE(Kernel_SVC, "called");
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
@ -1158,7 +1161,7 @@ static ResultCode AcceptSession(Handle* out_server_session, Handle server_port_h
} }
static ResultCode GetSystemInfo(s64* out, u32 type, s32 param) { static ResultCode GetSystemInfo(s64* out, u32 type, s32 param) {
LOG_TRACE(Kernel_SVC, "called type=%u param=%d", type, param); NGLOG_TRACE(Kernel_SVC, "called type={} param={}", type, param);
switch ((SystemInfoType)type) { switch ((SystemInfoType)type) {
case SystemInfoType::REGION_MEMORY_USAGE: case SystemInfoType::REGION_MEMORY_USAGE:
@ -1178,20 +1181,20 @@ static ResultCode GetSystemInfo(s64* out, u32 type, s32 param) {
*out = GetMemoryRegion(MemoryRegion::BASE)->used; *out = GetMemoryRegion(MemoryRegion::BASE)->used;
break; break;
default: default:
LOG_ERROR(Kernel_SVC, "unknown GetSystemInfo type=0 region: param=%d", param); NGLOG_ERROR(Kernel_SVC, "unknown GetSystemInfo type=0 region: param={}", param);
*out = 0; *out = 0;
break; break;
} }
break; break;
case SystemInfoType::KERNEL_ALLOCATED_PAGES: case SystemInfoType::KERNEL_ALLOCATED_PAGES:
LOG_ERROR(Kernel_SVC, "unimplemented GetSystemInfo type=2 param=%d", param); NGLOG_ERROR(Kernel_SVC, "unimplemented GetSystemInfo type=2 param={}", param);
*out = 0; *out = 0;
break; break;
case SystemInfoType::KERNEL_SPAWNED_PIDS: case SystemInfoType::KERNEL_SPAWNED_PIDS:
*out = 5; *out = 5;
break; break;
default: default:
LOG_ERROR(Kernel_SVC, "unknown GetSystemInfo type=%u param=%d", type, param); NGLOG_ERROR(Kernel_SVC, "unknown GetSystemInfo type={} param={}", type, param);
*out = 0; *out = 0;
break; break;
} }
@ -1201,7 +1204,7 @@ static ResultCode GetSystemInfo(s64* out, u32 type, s32 param) {
} }
static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) { static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) {
LOG_TRACE(Kernel_SVC, "called process=0x%08X type=%u", process_handle, type); NGLOG_TRACE(Kernel_SVC, "called process=0x{:08X} type={}", process_handle, type);
SharedPtr<Process> process = g_handle_table.Get<Process>(process_handle); SharedPtr<Process> process = g_handle_table.Get<Process>(process_handle);
if (process == nullptr) if (process == nullptr)
@ -1214,7 +1217,7 @@ static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) {
// what's the difference between them. // what's the difference between them.
*out = process->heap_used + process->linear_heap_used + process->misc_memory_used; *out = process->heap_used + process->linear_heap_used + process->misc_memory_used;
if (*out % Memory::PAGE_SIZE != 0) { if (*out % Memory::PAGE_SIZE != 0) {
LOG_ERROR(Kernel_SVC, "called, memory size not page-aligned"); NGLOG_ERROR(Kernel_SVC, "called, memory size not page-aligned");
return ERR_MISALIGNED_SIZE; return ERR_MISALIGNED_SIZE;
} }
break; break;
@ -1226,7 +1229,7 @@ static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) {
case 7: case 7:
case 8: case 8:
// These are valid, but not implemented yet // These are valid, but not implemented yet
LOG_ERROR(Kernel_SVC, "unimplemented GetProcessInfo type=%u", type); NGLOG_ERROR(Kernel_SVC, "unimplemented GetProcessInfo type={}", type);
break; break;
case 20: case 20:
*out = Memory::FCRAM_PADDR - process->GetLinearHeapAreaAddress(); *out = Memory::FCRAM_PADDR - process->GetLinearHeapAreaAddress();
@ -1235,10 +1238,10 @@ static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) {
case 22: case 22:
case 23: case 23:
// These return a different error value than higher invalid values // These return a different error value than higher invalid values
LOG_ERROR(Kernel_SVC, "unknown GetProcessInfo type=%u", type); NGLOG_ERROR(Kernel_SVC, "unknown GetProcessInfo type={}", type);
return ERR_NOT_IMPLEMENTED; return ERR_NOT_IMPLEMENTED;
default: default:
LOG_ERROR(Kernel_SVC, "unknown GetProcessInfo type=%u", type); NGLOG_ERROR(Kernel_SVC, "unknown GetProcessInfo type={}", type);
return ERR_INVALID_ENUM_VALUE; return ERR_INVALID_ENUM_VALUE;
} }
@ -1386,7 +1389,7 @@ static const FunctionDef SVC_Table[] = {
static const FunctionDef* GetSVCInfo(u32 func_num) { static const FunctionDef* GetSVCInfo(u32 func_num) {
if (func_num >= ARRAY_SIZE(SVC_Table)) { if (func_num >= ARRAY_SIZE(SVC_Table)) {
LOG_ERROR(Kernel_SVC, "unknown svc=0x%02X", func_num); NGLOG_ERROR(Kernel_SVC, "unknown svc=0x{:02X}", func_num);
return nullptr; return nullptr;
} }
return &SVC_Table[func_num]; return &SVC_Table[func_num];
@ -1408,7 +1411,7 @@ void CallSVC(u32 immediate) {
if (info->func) { if (info->func) {
info->func(); info->func();
} else { } else {
LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name); NGLOG_ERROR(Kernel_SVC, "unimplemented SVC function {}(..)", info->name);
} }
} }
} }

View File

@ -191,7 +191,7 @@ void ExitCurrentThread() {
static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) { static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) {
SharedPtr<Thread> thread = wakeup_callback_handle_table.Get<Thread>((Handle)thread_handle); SharedPtr<Thread> thread = wakeup_callback_handle_table.Get<Thread>((Handle)thread_handle);
if (thread == nullptr) { if (thread == nullptr) {
LOG_CRITICAL(Kernel, "Callback fired for invalid thread %08X", (Handle)thread_handle); NGLOG_CRITICAL(Kernel, "Callback fired for invalid thread {:08X}", (Handle)thread_handle);
return; return;
} }
@ -264,16 +264,16 @@ void Thread::ResumeFromWait() {
static void DebugThreadQueue() { static void DebugThreadQueue() {
Thread* thread = GetCurrentThread(); Thread* thread = GetCurrentThread();
if (!thread) { if (!thread) {
LOG_DEBUG(Kernel, "Current: NO CURRENT THREAD"); NGLOG_DEBUG(Kernel, "Current: NO CURRENT THREAD");
} else { } else {
LOG_DEBUG(Kernel, "0x%02X %u (current)", thread->current_priority, NGLOG_DEBUG(Kernel, "0x{:02X} {} (current)", thread->current_priority,
GetCurrentThread()->GetObjectId()); GetCurrentThread()->GetObjectId());
} }
for (auto& t : thread_list) { for (auto& t : thread_list) {
u32 priority = ready_queue.contains(t.get()); u32 priority = ready_queue.contains(t.get());
if (priority != -1) { if (priority != -1) {
LOG_DEBUG(Kernel, "0x%02X %u", priority, t->GetObjectId()); NGLOG_DEBUG(Kernel, "0x{:02X} {}", priority, t->GetObjectId());
} }
} }
} }
@ -324,19 +324,19 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
SharedPtr<Process> owner_process) { SharedPtr<Process> owner_process) {
// Check if priority is in ranged. Lowest priority -> highest priority id. // Check if priority is in ranged. Lowest priority -> highest priority id.
if (priority > THREADPRIO_LOWEST) { if (priority > THREADPRIO_LOWEST) {
LOG_ERROR(Kernel_SVC, "Invalid thread priority: %d", priority); NGLOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority);
return ERR_OUT_OF_RANGE; return ERR_OUT_OF_RANGE;
} }
if (processor_id > THREADPROCESSORID_MAX) { if (processor_id > THREADPROCESSORID_MAX) {
LOG_ERROR(Kernel_SVC, "Invalid processor id: %d", processor_id); NGLOG_ERROR(Kernel_SVC, "Invalid processor id: {}", processor_id);
return ERR_OUT_OF_RANGE_KERNEL; return ERR_OUT_OF_RANGE_KERNEL;
} }
// TODO(yuriks): Other checks, returning 0xD9001BEA // TODO(yuriks): Other checks, returning 0xD9001BEA
if (!Memory::IsValidVirtualAddress(*owner_process, entry_point)) { if (!Memory::IsValidVirtualAddress(*owner_process, entry_point)) {
LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %08x", name.c_str(), entry_point); NGLOG_ERROR(Kernel_SVC, "(name={}): invalid entry {:08x}", name, entry_point);
// TODO: Verify error // TODO: Verify error
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent); ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
@ -375,8 +375,8 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
auto& linheap_memory = memory_region->linear_heap_memory; auto& linheap_memory = memory_region->linear_heap_memory;
if (linheap_memory->size() + Memory::PAGE_SIZE > memory_region->size) { if (linheap_memory->size() + Memory::PAGE_SIZE > memory_region->size) {
LOG_ERROR(Kernel_SVC, NGLOG_ERROR(Kernel_SVC,
"Not enough space in region to allocate a new TLS page for thread"); "Not enough space in region to allocate a new TLS page for thread");
return ERR_OUT_OF_MEMORY; return ERR_OUT_OF_MEMORY;
} }
@ -469,11 +469,11 @@ void Reschedule() {
Thread* next = PopNextReadyThread(); Thread* next = PopNextReadyThread();
if (cur && next) { if (cur && next) {
LOG_TRACE(Kernel, "context switch %u -> %u", cur->GetObjectId(), next->GetObjectId()); NGLOG_TRACE(Kernel, "context switch {} -> {}", cur->GetObjectId(), next->GetObjectId());
} else if (cur) { } else if (cur) {
LOG_TRACE(Kernel, "context switch %u -> idle", cur->GetObjectId()); NGLOG_TRACE(Kernel, "context switch {} -> idle", cur->GetObjectId());
} else if (next) { } else if (next) {
LOG_TRACE(Kernel, "context switch idle -> %u", next->GetObjectId()); NGLOG_TRACE(Kernel, "context switch idle -> {}", next->GetObjectId());
} }
SwitchContext(next); SwitchContext(next);

View File

@ -77,7 +77,7 @@ void Timer::WakeupAllWaitingThreads() {
} }
void Timer::Signal(int cycles_late) { void Timer::Signal(int cycles_late) {
LOG_TRACE(Kernel, "Timer %u fired", GetObjectId()); NGLOG_TRACE(Kernel, "Timer {} fired", GetObjectId());
signaled = true; signaled = true;
@ -97,7 +97,7 @@ static void TimerCallback(u64 timer_handle, int cycles_late) {
timer_callback_handle_table.Get<Timer>(static_cast<Handle>(timer_handle)); timer_callback_handle_table.Get<Timer>(static_cast<Handle>(timer_handle));
if (timer == nullptr) { if (timer == nullptr) {
LOG_CRITICAL(Kernel, "Callback fired for invalid timer %08" PRIx64, timer_handle); NGLOG_CRITICAL(Kernel, "Callback fired for invalid timer {:08x}", timer_handle);
return; return;
} }

View File

@ -260,12 +260,12 @@ void VMManager::RefreshMemoryBlockMappings(const std::vector<u8>* block) {
void VMManager::LogLayout(Log::Level log_level) const { void VMManager::LogLayout(Log::Level log_level) const {
for (const auto& p : vma_map) { for (const auto& p : vma_map) {
const VirtualMemoryArea& vma = p.second; const VirtualMemoryArea& vma = p.second;
LOG_GENERIC(Log::Class::Kernel, log_level, "%08X - %08X size: %8X %c%c%c %s", vma.base, NGLOG_GENERIC(::Log::Class::Kernel, log_level, "{:08X} - {:08X} size: {:8X} {}{}{} {}",
vma.base + vma.size, vma.size, vma.base, vma.base + vma.size, vma.size,
(u8)vma.permissions & (u8)VMAPermission::Read ? 'R' : '-', (u8)vma.permissions & (u8)VMAPermission::Read ? 'R' : '-',
(u8)vma.permissions & (u8)VMAPermission::Write ? 'W' : '-', (u8)vma.permissions & (u8)VMAPermission::Write ? 'W' : '-',
(u8)vma.permissions & (u8)VMAPermission::Execute ? 'X' : '-', (u8)vma.permissions & (u8)VMAPermission::Execute ? 'X' : '-',
GetMemoryStateName(vma.meminfo_state)); GetMemoryStateName(vma.meminfo_state));
} }
} }