hw: Migrate logging macros (#3584)

* hw: Migrate logging macros

Use NGLOG instead of LOG prefixed macros for logging

* gpu: Remove unnecessary casting

At first this line without any casting gave an error. Without knowing which argument is causing the error, I just casted everything. After that forgot to check which argument is the one causing trouble.

* hw: Change format specifiers for the one missed
This commit is contained in:
Daniel Lim Wee Soong 2018-03-27 19:02:19 +08:00 committed by Merry
parent 3e8e011c33
commit 7abfdb164b
5 changed files with 64 additions and 58 deletions

View file

@ -46,7 +46,7 @@ public:
std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& nonce, std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& nonce,
size_t slot_id) { size_t slot_id) {
if (!IsNormalKeyAvailable(slot_id)) { if (!IsNormalKeyAvailable(slot_id)) {
LOG_ERROR(HW_AES, "Key slot %zu not available. Will use zero key.", slot_id); NGLOG_ERROR(HW_AES, "Key slot {} not available. Will use zero key.", slot_id);
} }
const AESKey normal = GetNormalKey(slot_id); const AESKey normal = GetNormalKey(slot_id);
std::vector<u8> cipher(pdata.size() + CCM_MAC_SIZE); std::vector<u8> cipher(pdata.size() + CCM_MAC_SIZE);
@ -59,7 +59,7 @@ std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& non
new CryptoPP::AuthenticatedEncryptionFilter( new CryptoPP::AuthenticatedEncryptionFilter(
e, new CryptoPP::ArraySink(cipher.data(), cipher.size()))); e, new CryptoPP::ArraySink(cipher.data(), cipher.size())));
} catch (const CryptoPP::Exception& e) { } catch (const CryptoPP::Exception& e) {
LOG_ERROR(HW_AES, "FAILED with: %s", e.what()); NGLOG_ERROR(HW_AES, "FAILED with: {}", e.what());
} }
return cipher; return cipher;
} }
@ -67,7 +67,7 @@ std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& non
std::vector<u8> DecryptVerifyCCM(const std::vector<u8>& cipher, const CCMNonce& nonce, std::vector<u8> DecryptVerifyCCM(const std::vector<u8>& cipher, const CCMNonce& nonce,
size_t slot_id) { size_t slot_id) {
if (!IsNormalKeyAvailable(slot_id)) { if (!IsNormalKeyAvailable(slot_id)) {
LOG_ERROR(HW_AES, "Key slot %zu not available. Will use zero key.", slot_id); NGLOG_ERROR(HW_AES, "Key slot {} not available. Will use zero key.", slot_id);
} }
const AESKey normal = GetNormalKey(slot_id); const AESKey normal = GetNormalKey(slot_id);
const std::size_t pdata_size = cipher.size() - CCM_MAC_SIZE; const std::size_t pdata_size = cipher.size() - CCM_MAC_SIZE;
@ -81,11 +81,11 @@ std::vector<u8> DecryptVerifyCCM(const std::vector<u8>& cipher, const CCMNonce&
d, new CryptoPP::ArraySink(pdata.data(), pdata_size)); d, new CryptoPP::ArraySink(pdata.data(), pdata_size));
CryptoPP::ArraySource as(cipher.data(), cipher.size(), true, new CryptoPP::Redirector(df)); CryptoPP::ArraySource as(cipher.data(), cipher.size(), true, new CryptoPP::Redirector(df));
if (!df.GetLastResult()) { if (!df.GetLastResult()) {
LOG_ERROR(HW_AES, "FAILED"); NGLOG_ERROR(HW_AES, "FAILED");
return {}; return {};
} }
} catch (const CryptoPP::Exception& e) { } catch (const CryptoPP::Exception& e) {
LOG_ERROR(HW_AES, "FAILED with: %s", e.what()); NGLOG_ERROR(HW_AES, "FAILED with: {}", e.what());
return {}; return {};
} }
return pdata; return pdata;

View file

@ -91,7 +91,7 @@ void LoadPresetKeys() {
std::vector<std::string> parts; std::vector<std::string> parts;
Common::SplitString(line, '=', parts); Common::SplitString(line, '=', parts);
if (parts.size() != 2) { if (parts.size() != 2) {
LOG_ERROR(HW_AES, "Failed to parse %s", line.c_str()); NGLOG_ERROR(HW_AES, "Failed to parse {}", line);
continue; continue;
} }
@ -100,7 +100,7 @@ void LoadPresetKeys() {
try { try {
key = HexToKey(parts[1]); key = HexToKey(parts[1]);
} catch (const std::logic_error& e) { } catch (const std::logic_error& e) {
LOG_ERROR(HW_AES, "Invalid key %s: %s", parts[1].c_str(), e.what()); NGLOG_ERROR(HW_AES, "Invalid key {}: {}", parts[1], e.what());
continue; continue;
} }
@ -112,12 +112,12 @@ void LoadPresetKeys() {
size_t slot_id; size_t slot_id;
char key_type; char key_type;
if (std::sscanf(name.c_str(), "slot0x%zXKey%c", &slot_id, &key_type) != 2) { if (std::sscanf(name.c_str(), "slot0x%zXKey%c", &slot_id, &key_type) != 2) {
LOG_ERROR(HW_AES, "Invalid key name %s", name.c_str()); NGLOG_ERROR(HW_AES, "Invalid key name {}", name);
continue; continue;
} }
if (slot_id >= MaxKeySlotID) { if (slot_id >= MaxKeySlotID) {
LOG_ERROR(HW_AES, "Out of range slot ID 0x%zX", slot_id); NGLOG_ERROR(HW_AES, "Out of range slot ID {:#X}", slot_id);
continue; continue;
} }
@ -132,7 +132,7 @@ void LoadPresetKeys() {
key_slots.at(slot_id).SetNormalKey(key); key_slots.at(slot_id).SetNormalKey(key);
break; break;
default: default:
LOG_ERROR(HW_AES, "Invalid key type %c", key_type); NGLOG_ERROR(HW_AES, "Invalid key type {}", key_type);
break; break;
} }
} }

View file

@ -40,7 +40,7 @@ inline void Read(T& var, const u32 raw_addr) {
// Reads other than u32 are untested, so I'd rather have them abort than silently fail // Reads other than u32 are untested, so I'd rather have them abort than silently fail
if (index >= Regs::NumIds() || !std::is_same<T, u32>::value) { if (index >= Regs::NumIds() || !std::is_same<T, u32>::value) {
LOG_ERROR(HW_GPU, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, addr); NGLOG_ERROR(HW_GPU, "unknown Read{} @ {:#010X}", sizeof(var) * 8, addr);
return; return;
} }
@ -65,7 +65,8 @@ static Math::Vec4<u8> DecodePixel(Regs::PixelFormat input_format, const u8* src_
return Color::DecodeRGBA4(src_pixel); return Color::DecodeRGBA4(src_pixel);
default: default:
LOG_ERROR(HW_GPU, "Unknown source framebuffer format %x", static_cast<u32>(input_format)); NGLOG_ERROR(HW_GPU, "Unknown source framebuffer format {:x}",
static_cast<u32>(input_format));
return {0, 0, 0, 0}; return {0, 0, 0, 0};
} }
} }
@ -79,17 +80,18 @@ static void MemoryFill(const Regs::MemoryFillConfig& config) {
// TODO: do hwtest with these cases // TODO: do hwtest with these cases
if (!Memory::IsValidPhysicalAddress(start_addr)) { if (!Memory::IsValidPhysicalAddress(start_addr)) {
LOG_CRITICAL(HW_GPU, "invalid start address 0x%08X", start_addr); NGLOG_CRITICAL(HW_GPU, "invalid start address {:#010X}", start_addr);
return; return;
} }
if (!Memory::IsValidPhysicalAddress(end_addr)) { if (!Memory::IsValidPhysicalAddress(end_addr)) {
LOG_CRITICAL(HW_GPU, "invalid end address 0x%08X", end_addr); NGLOG_CRITICAL(HW_GPU, "invalid end address {:#010X}", end_addr);
return; return;
} }
if (end_addr <= start_addr) { if (end_addr <= start_addr) {
LOG_CRITICAL(HW_GPU, "invalid memory range from 0x%08X to 0x%08X", start_addr, end_addr); NGLOG_CRITICAL(HW_GPU, "invalid memory range from {:#010X} to {:#010X}", start_addr,
end_addr);
return; return;
} }
@ -131,32 +133,32 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) {
// TODO: do hwtest with these cases // TODO: do hwtest with these cases
if (!Memory::IsValidPhysicalAddress(src_addr)) { if (!Memory::IsValidPhysicalAddress(src_addr)) {
LOG_CRITICAL(HW_GPU, "invalid input address 0x%08X", src_addr); NGLOG_CRITICAL(HW_GPU, "invalid input address {:#010X}", src_addr);
return; return;
} }
if (!Memory::IsValidPhysicalAddress(dst_addr)) { if (!Memory::IsValidPhysicalAddress(dst_addr)) {
LOG_CRITICAL(HW_GPU, "invalid output address 0x%08X", dst_addr); NGLOG_CRITICAL(HW_GPU, "invalid output address {:#010X}", dst_addr);
return; return;
} }
if (config.input_width == 0) { if (config.input_width == 0) {
LOG_CRITICAL(HW_GPU, "zero input width"); NGLOG_CRITICAL(HW_GPU, "zero input width");
return; return;
} }
if (config.input_height == 0) { if (config.input_height == 0) {
LOG_CRITICAL(HW_GPU, "zero input height"); NGLOG_CRITICAL(HW_GPU, "zero input height");
return; return;
} }
if (config.output_width == 0) { if (config.output_width == 0) {
LOG_CRITICAL(HW_GPU, "zero output width"); NGLOG_CRITICAL(HW_GPU, "zero output width");
return; return;
} }
if (config.output_height == 0) { if (config.output_height == 0) {
LOG_CRITICAL(HW_GPU, "zero output height"); NGLOG_CRITICAL(HW_GPU, "zero output height");
return; return;
} }
@ -167,14 +169,14 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) {
u8* dst_pointer = Memory::GetPhysicalPointer(dst_addr); u8* dst_pointer = Memory::GetPhysicalPointer(dst_addr);
if (config.scaling > config.ScaleXY) { if (config.scaling > config.ScaleXY) {
LOG_CRITICAL(HW_GPU, "Unimplemented display transfer scaling mode %u", NGLOG_CRITICAL(HW_GPU, "Unimplemented display transfer scaling mode {}",
config.scaling.Value()); config.scaling.Value());
UNIMPLEMENTED(); UNIMPLEMENTED();
return; return;
} }
if (config.input_linear && config.scaling != config.NoScale) { if (config.input_linear && config.scaling != config.NoScale) {
LOG_CRITICAL(HW_GPU, "Scaling is only implemented on tiled input"); NGLOG_CRITICAL(HW_GPU, "Scaling is only implemented on tiled input");
UNIMPLEMENTED(); UNIMPLEMENTED();
return; return;
} }
@ -293,8 +295,8 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) {
break; break;
default: default:
LOG_ERROR(HW_GPU, "Unknown destination framebuffer format %x", NGLOG_ERROR(HW_GPU, "Unknown destination framebuffer format {:x}",
static_cast<u32>(config.output_format.Value())); static_cast<u32>(config.output_format.Value()));
break; break;
} }
} }
@ -307,12 +309,12 @@ static void TextureCopy(const Regs::DisplayTransferConfig& config) {
// TODO: do hwtest with invalid addresses // TODO: do hwtest with invalid addresses
if (!Memory::IsValidPhysicalAddress(src_addr)) { if (!Memory::IsValidPhysicalAddress(src_addr)) {
LOG_CRITICAL(HW_GPU, "invalid input address 0x%08X", src_addr); NGLOG_CRITICAL(HW_GPU, "invalid input address {:#010X}", src_addr);
return; return;
} }
if (!Memory::IsValidPhysicalAddress(dst_addr)) { if (!Memory::IsValidPhysicalAddress(dst_addr)) {
LOG_CRITICAL(HW_GPU, "invalid output address 0x%08X", dst_addr); NGLOG_CRITICAL(HW_GPU, "invalid output address {:#010X}", dst_addr);
return; return;
} }
@ -325,7 +327,7 @@ static void TextureCopy(const Regs::DisplayTransferConfig& config) {
u32 remaining_size = Common::AlignDown(config.texture_copy.size, 16); u32 remaining_size = Common::AlignDown(config.texture_copy.size, 16);
if (remaining_size == 0) { if (remaining_size == 0) {
LOG_CRITICAL(HW_GPU, "zero size. Real hardware freezes on this."); NGLOG_CRITICAL(HW_GPU, "zero size. Real hardware freezes on this.");
return; return;
} }
@ -338,12 +340,12 @@ static void TextureCopy(const Regs::DisplayTransferConfig& config) {
u32 output_width = output_gap == 0 ? remaining_size : config.texture_copy.output_width * 16; u32 output_width = output_gap == 0 ? remaining_size : config.texture_copy.output_width * 16;
if (input_width == 0) { if (input_width == 0) {
LOG_CRITICAL(HW_GPU, "zero input width. Real hardware freezes on this."); NGLOG_CRITICAL(HW_GPU, "zero input width. Real hardware freezes on this.");
return; return;
} }
if (output_width == 0) { if (output_width == 0) {
LOG_CRITICAL(HW_GPU, "zero output width. Real hardware freezes on this."); NGLOG_CRITICAL(HW_GPU, "zero output width. Real hardware freezes on this.");
return; return;
} }
@ -390,7 +392,8 @@ inline void Write(u32 addr, const T data) {
// Writes other than u32 are untested, so I'd rather have them abort than silently fail // Writes other than u32 are untested, so I'd rather have them abort than silently fail
if (index >= Regs::NumIds() || !std::is_same<T, u32>::value) { if (index >= Regs::NumIds() || !std::is_same<T, u32>::value) {
LOG_ERROR(HW_GPU, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, addr); NGLOG_ERROR(HW_GPU, "unknown Write{} {:#010X} @ {:#010X}", sizeof(data) * 8, (u32)data,
addr);
return; return;
} }
@ -406,8 +409,8 @@ inline void Write(u32 addr, const T data) {
if (config.trigger) { if (config.trigger) {
MemoryFill(config); MemoryFill(config);
LOG_TRACE(HW_GPU, "MemoryFill from 0x%08x to 0x%08x", config.GetStartAddress(), NGLOG_TRACE(HW_GPU, "MemoryFill from {:#010X} to {:#010X}", config.GetStartAddress(),
config.GetEndAddress()); config.GetEndAddress());
// It seems that it won't signal interrupt if "address_start" is zero. // It seems that it won't signal interrupt if "address_start" is zero.
// TODO: hwtest this // TODO: hwtest this
@ -439,22 +442,23 @@ inline void Write(u32 addr, const T data) {
if (config.is_texture_copy) { if (config.is_texture_copy) {
TextureCopy(config); TextureCopy(config);
LOG_TRACE(HW_GPU, NGLOG_TRACE(HW_GPU,
"TextureCopy: 0x%X bytes from 0x%08X(%u+%u)-> " "TextureCopy: {:#X} bytes from {:#010X}({}+{})-> "
"0x%08X(%u+%u), flags 0x%08X", "{:#010X}({}+{}), flags {:#010X}",
config.texture_copy.size, config.GetPhysicalInputAddress(), config.texture_copy.size, config.GetPhysicalInputAddress(),
config.texture_copy.input_width * 16, config.texture_copy.input_gap * 16, config.texture_copy.input_width * 16,
config.GetPhysicalOutputAddress(), config.texture_copy.output_width * 16, config.texture_copy.input_gap * 16, config.GetPhysicalOutputAddress(),
config.texture_copy.output_gap * 16, config.flags); config.texture_copy.output_width * 16,
config.texture_copy.output_gap * 16, config.flags);
} else { } else {
DisplayTransfer(config); DisplayTransfer(config);
LOG_TRACE(HW_GPU, NGLOG_TRACE(HW_GPU,
"DisplayTransfer: 0x%08x(%ux%u)-> " "DisplayTransfer: {:#010X}({}x{})-> "
"0x%08x(%ux%u), dst format %x, flags 0x%08X", "{:#010X}({}x{}), dst format {:x}, flags {:#010X}",
config.GetPhysicalInputAddress(), config.input_width.Value(), config.GetPhysicalInputAddress(), config.input_width.Value(),
config.input_height.Value(), config.GetPhysicalOutputAddress(), config.input_height.Value(), config.GetPhysicalOutputAddress(),
config.output_width.Value(), config.output_height.Value(), config.output_width.Value(), config.output_height.Value(),
config.output_format.Value(), config.flags); static_cast<u32>(config.output_format.Value()), config.flags);
} }
g_regs.display_transfer_config.trigger = 0; g_regs.display_transfer_config.trigger = 0;
@ -557,12 +561,12 @@ void Init() {
vblank_event = CoreTiming::RegisterEvent("GPU::VBlankCallback", VBlankCallback); vblank_event = CoreTiming::RegisterEvent("GPU::VBlankCallback", VBlankCallback);
CoreTiming::ScheduleEvent(frame_ticks, vblank_event); CoreTiming::ScheduleEvent(frame_ticks, vblank_event);
LOG_DEBUG(HW_GPU, "initialized OK"); NGLOG_DEBUG(HW_GPU, "initialized OK");
} }
/// Shutdown hardware /// Shutdown hardware
void Shutdown() { void Shutdown() {
LOG_DEBUG(HW_GPU, "shutdown OK"); NGLOG_DEBUG(HW_GPU, "shutdown OK");
} }
} // namespace GPU } // namespace GPU

View file

@ -36,7 +36,7 @@ inline void Read(T& var, const u32 addr) {
LCD::Read(var, addr); LCD::Read(var, addr);
break; break;
default: default:
LOG_ERROR(HW_Memory, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, addr); NGLOG_ERROR(HW_Memory, "unknown Read{} @ {:#010X}", sizeof(var) * 8, addr);
} }
} }
@ -65,7 +65,8 @@ inline void Write(u32 addr, const T data) {
LCD::Write(addr, data); LCD::Write(addr, data);
break; break;
default: default:
LOG_ERROR(HW_Memory, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, addr); NGLOG_ERROR(HW_Memory, "unknown Write{} {:#010X} @ {:#010X}", sizeof(data) * 8, (u32)data,
addr);
} }
} }
@ -89,13 +90,13 @@ void Init() {
AES::InitKeys(); AES::InitKeys();
GPU::Init(); GPU::Init();
LCD::Init(); LCD::Init();
LOG_DEBUG(HW, "initialized OK"); NGLOG_DEBUG(HW, "initialized OK");
} }
/// Shutdown hardware /// Shutdown hardware
void Shutdown() { void Shutdown() {
GPU::Shutdown(); GPU::Shutdown();
LCD::Shutdown(); LCD::Shutdown();
LOG_DEBUG(HW, "shutdown OK"); NGLOG_DEBUG(HW, "shutdown OK");
} }
} // namespace HW } // namespace HW

View file

@ -21,7 +21,7 @@ inline void Read(T& var, const u32 raw_addr) {
// Reads other than u32 are untested, so I'd rather have them abort than silently fail // Reads other than u32 are untested, so I'd rather have them abort than silently fail
if (index >= 0x400 || !std::is_same<T, u32>::value) { if (index >= 0x400 || !std::is_same<T, u32>::value) {
LOG_ERROR(HW_LCD, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, addr); NGLOG_ERROR(HW_LCD, "unknown Read{} @ {:#010X}", sizeof(var) * 8, addr);
return; return;
} }
@ -35,7 +35,8 @@ inline void Write(u32 addr, const T data) {
// Writes other than u32 are untested, so I'd rather have them abort than silently fail // Writes other than u32 are untested, so I'd rather have them abort than silently fail
if (index >= 0x400 || !std::is_same<T, u32>::value) { if (index >= 0x400 || !std::is_same<T, u32>::value) {
LOG_ERROR(HW_LCD, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data, addr); NGLOG_ERROR(HW_LCD, "unknown Write{} {:#010X} @ {:#010X}", sizeof(data) * 8, (u32)data,
addr);
return; return;
} }
@ -65,12 +66,12 @@ template void Write<u8>(u32 addr, const u8 data);
/// Initialize hardware /// Initialize hardware
void Init() { void Init() {
memset(&g_regs, 0, sizeof(g_regs)); memset(&g_regs, 0, sizeof(g_regs));
LOG_DEBUG(HW_LCD, "initialized OK"); NGLOG_DEBUG(HW_LCD, "initialized OK");
} }
/// Shutdown hardware /// Shutdown hardware
void Shutdown() { void Shutdown() {
LOG_DEBUG(HW_LCD, "shutdown OK"); NGLOG_DEBUG(HW_LCD, "shutdown OK");
} }
} // namespace LCD } // namespace LCD