mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-06-28 01:49:42 -06:00
Introduce Platform::Log
(#1640)
* Add Platform::Log and Platform::LogLevel * Replace most printf calls with Platform::Log calls * Move a brace down * Move some log entries to one Log call - Some implementations of Log may assume a full line * Log the MAC address as LogLevel::Info
This commit is contained in:

committed by
GitHub

parent
19280cff2d
commit
79dfb8dc8f
50
src/DSi.cpp
50
src/DSi.cpp
@ -43,6 +43,8 @@
|
||||
|
||||
#include "tiny-AES-c/aes.hpp"
|
||||
|
||||
using Platform::Log;
|
||||
using Platform::LogLevel;
|
||||
|
||||
namespace DSi
|
||||
{
|
||||
@ -692,7 +694,7 @@ bool LoadBIOS()
|
||||
f = Platform::OpenLocalFile(Platform::GetConfigString(Platform::DSi_BIOS9Path), "rb");
|
||||
if (!f)
|
||||
{
|
||||
printf("ARM9i BIOS not found\n");
|
||||
Log(LogLevel::Warn, "ARM9i BIOS not found\n");
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
((u32*)ARM9iBIOS)[i] = 0xE7FFDEFF;
|
||||
@ -702,14 +704,14 @@ bool LoadBIOS()
|
||||
fseek(f, 0, SEEK_SET);
|
||||
fread(ARM9iBIOS, 0x10000, 1, f);
|
||||
|
||||
printf("ARM9i BIOS loaded\n");
|
||||
Log(LogLevel::Info, "ARM9i BIOS loaded\n");
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
f = Platform::OpenLocalFile(Platform::GetConfigString(Platform::DSi_BIOS7Path), "rb");
|
||||
if (!f)
|
||||
{
|
||||
printf("ARM7i BIOS not found\n");
|
||||
Log(LogLevel::Warn, "ARM7i BIOS not found\n");
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
((u32*)ARM7iBIOS)[i] = 0xE7FFDEFF;
|
||||
@ -721,7 +723,7 @@ bool LoadBIOS()
|
||||
fseek(f, 0, SEEK_SET);
|
||||
fread(ARM7iBIOS, 0x10000, 1, f);
|
||||
|
||||
printf("ARM7i BIOS loaded\n");
|
||||
Log(LogLevel::Info, "ARM7i BIOS loaded\n");
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
@ -737,11 +739,11 @@ bool LoadBIOS()
|
||||
|
||||
bool LoadNAND()
|
||||
{
|
||||
printf("Loading DSi NAND\n");
|
||||
Log(LogLevel::Info, "Loading DSi NAND\n");
|
||||
|
||||
if (!DSi_NAND::Init(&DSi::ARM7iBIOS[0x8308]))
|
||||
{
|
||||
printf("Failed to load DSi NAND\n");
|
||||
Log(LogLevel::Error, "Failed to load DSi NAND\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -770,9 +772,9 @@ bool LoadNAND()
|
||||
fseek(nand, 0x220, SEEK_SET);
|
||||
fread(bootparams, 4, 8, nand);
|
||||
|
||||
printf("ARM9: offset=%08X size=%08X RAM=%08X size_aligned=%08X\n",
|
||||
Log(LogLevel::Debug, "ARM9: offset=%08X size=%08X RAM=%08X size_aligned=%08X\n",
|
||||
bootparams[0], bootparams[1], bootparams[2], bootparams[3]);
|
||||
printf("ARM7: offset=%08X size=%08X RAM=%08X size_aligned=%08X\n",
|
||||
Log(LogLevel::Debug, "ARM7: offset=%08X size=%08X RAM=%08X size_aligned=%08X\n",
|
||||
bootparams[4], bootparams[5], bootparams[6], bootparams[7]);
|
||||
|
||||
// read and apply new-WRAM settings
|
||||
@ -883,8 +885,8 @@ bool LoadNAND()
|
||||
|
||||
DSi_NAND::GetIDs(eMMC_CID, ConsoleID);
|
||||
|
||||
printf("eMMC CID: "); printhex(eMMC_CID, 16);
|
||||
printf("Console ID: %" PRIx64 "\n", ConsoleID);
|
||||
Log(LogLevel::Debug, "eMMC CID: "); printhex(eMMC_CID, 16);
|
||||
Log(LogLevel::Debug, "Console ID: %" PRIx64 "\n", ConsoleID);
|
||||
|
||||
u32 eaddr = 0x03FFE6E4;
|
||||
ARM7Write32(eaddr+0x00, *(u32*)&eMMC_CID[0]);
|
||||
@ -1003,7 +1005,7 @@ void MapNWRAM_A(u32 num, u8 val)
|
||||
|
||||
if (MBK[0][8] & (1 << num))
|
||||
{
|
||||
printf("trying to map NWRAM_A %d to %02X, but it is write-protected (%08X)\n", num, val, MBK[0][8]);
|
||||
Log(LogLevel::Warn, "trying to map NWRAM_A %d to %02X, but it is write-protected (%08X)\n", num, val, MBK[0][8]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1050,7 +1052,7 @@ void MapNWRAM_B(u32 num, u8 val)
|
||||
|
||||
if (MBK[0][8] & (1 << (8+num)))
|
||||
{
|
||||
printf("trying to map NWRAM_B %d to %02X, but it is write-protected (%08X)\n", num, val, MBK[0][8]);
|
||||
Log(LogLevel::Warn, "trying to map NWRAM_B %d to %02X, but it is write-protected (%08X)\n", num, val, MBK[0][8]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1099,7 +1101,7 @@ void MapNWRAM_C(u32 num, u8 val)
|
||||
|
||||
if (MBK[0][8] & (1 << (16+num)))
|
||||
{
|
||||
printf("trying to map NWRAM_C %d to %02X, but it is write-protected (%08X)\n", num, val, MBK[0][8]);
|
||||
Log(LogLevel::Warn, "trying to map NWRAM_C %d to %02X, but it is write-protected (%08X)\n", num, val, MBK[0][8]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1179,7 +1181,7 @@ void MapNWRAMRange(u32 cpu, u32 num, u32 val)
|
||||
u32 end = 0x03000000 + (((val >> 20) & 0x1FF) << 16);
|
||||
u32 size = (val >> 12) & 0x3;
|
||||
|
||||
printf("NWRAM-A: ARM%d range %08X-%08X, size %d\n", cpu?7:9, start, end, size);
|
||||
Log(LogLevel::Debug, "NWRAM-A: ARM%d range %08X-%08X, size %d\n", cpu?7:9, start, end, size);
|
||||
|
||||
NWRAMStart[cpu][num] = start;
|
||||
NWRAMEnd[cpu][num] = end;
|
||||
@ -1198,7 +1200,7 @@ void MapNWRAMRange(u32 cpu, u32 num, u32 val)
|
||||
u32 end = 0x03000000 + (((val >> 19) & 0x3FF) << 15);
|
||||
u32 size = (val >> 12) & 0x3;
|
||||
|
||||
printf("NWRAM-%c: ARM%d range %08X-%08X, size %d\n", 'A'+num, cpu?7:9, start, end, size);
|
||||
Log(LogLevel::Debug, "NWRAM-%c: ARM%d range %08X-%08X, size %d\n", 'A'+num, cpu?7:9, start, end, size);
|
||||
|
||||
NWRAMStart[cpu][num] = start;
|
||||
NWRAMEnd[cpu][num] = end;
|
||||
@ -1220,12 +1222,12 @@ void ApplyNewRAMSize(u32 size)
|
||||
case 0:
|
||||
case 1:
|
||||
NDS::MainRAMMask = 0x3FFFFF;
|
||||
printf("RAM: 4MB\n");
|
||||
Log(LogLevel::Debug, "RAM: 4MB\n");
|
||||
break;
|
||||
case 2:
|
||||
case 3: // TODO: debug console w/ 32MB?
|
||||
NDS::MainRAMMask = 0xFFFFFF;
|
||||
printf("RAM: 16MB\n");
|
||||
Log(LogLevel::Debug, "RAM: 16MB\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1236,7 +1238,7 @@ void Set_SCFG_Clock9(u16 val)
|
||||
NDS::ARM9Timestamp >>= NDS::ARM9ClockShift;
|
||||
NDS::ARM9Target >>= NDS::ARM9ClockShift;
|
||||
|
||||
printf("CLOCK9=%04X\n", val);
|
||||
Log(LogLevel::Debug, "CLOCK9=%04X\n", val);
|
||||
SCFG_Clock9 = val & 0x0187;
|
||||
|
||||
if (SCFG_Clock9 & (1<<0)) NDS::ARM9ClockShift = 2;
|
||||
@ -1253,7 +1255,7 @@ void Set_SCFG_MC(u32 val)
|
||||
|
||||
val &= 0xFFFF800C;
|
||||
if ((val & 0xC) == 0xC) val &= ~0xC; // hax
|
||||
if (val & 0x8000) printf("SCFG_MC: weird NDS slot swap\n");
|
||||
if (val & 0x8000) Log(LogLevel::Warn, "SCFG_MC: weird NDS slot swap\n");
|
||||
SCFG_MC = (SCFG_MC & ~0xFFFF800C) | val;
|
||||
|
||||
if ((oldslotstatus == 0x0) && ((SCFG_MC & 0xC) == 0x4))
|
||||
@ -2537,7 +2539,7 @@ void ARM9IOWrite32(u32 addr, u32 val)
|
||||
SCFG_EXT[0] |= (val & 0x8007F19F);
|
||||
SCFG_EXT[1] &= ~0x0000F080;
|
||||
SCFG_EXT[1] |= (val & 0x0000F080);
|
||||
printf("SCFG_EXT = %08X / %08X (val9 %08X)\n", SCFG_EXT[0], SCFG_EXT[1], val);
|
||||
Log(LogLevel::Debug, "SCFG_EXT = %08X / %08X (val9 %08X)\n", SCFG_EXT[0], SCFG_EXT[1], val);
|
||||
/*switch ((SCFG_EXT[0] >> 14) & 0x3)
|
||||
{
|
||||
case 0:
|
||||
@ -2558,7 +2560,7 @@ void ARM9IOWrite32(u32 addr, u32 val)
|
||||
// is still busy clearing/relocating shit
|
||||
//if (newram != oldram)
|
||||
// NDS::ScheduleEvent(NDS::Event_DSi_RAMSizeChange, false, 512*512*512, ApplyNewRAMSize, newram);
|
||||
printf("from %08X, ARM7 %08X, %08X\n", NDS::GetPC(0), NDS::GetPC(1), NDS::ARM7->R[1]);
|
||||
Log(LogLevel::Debug, "from %08X, ARM7 %08X, %08X\n", NDS::GetPC(0), NDS::GetPC(1), NDS::ARM7->R[1]);
|
||||
}
|
||||
return;
|
||||
|
||||
@ -2805,7 +2807,7 @@ u32 ARM7IORead32(u32 addr)
|
||||
case 0x04004D08: return 0;
|
||||
|
||||
case 0x4004700:
|
||||
printf("32-Bit SNDExCnt read? %08X\n", NDS::ARM7->R[15]);
|
||||
Log(LogLevel::Debug, "32-Bit SNDExCnt read? %08X\n", NDS::ARM7->R[15]);
|
||||
return DSi_DSP::SNDExCnt;
|
||||
}
|
||||
|
||||
@ -3005,7 +3007,7 @@ void ARM7IOWrite32(u32 addr, u32 val)
|
||||
SCFG_EXT[0] |= (val & 0x03000000);
|
||||
SCFG_EXT[1] &= ~0x93FF0F07;
|
||||
SCFG_EXT[1] |= (val & 0x93FF0F07);
|
||||
printf("SCFG_EXT = %08X / %08X (val7 %08X)\n", SCFG_EXT[0], SCFG_EXT[1], val);
|
||||
Log(LogLevel::Debug, "SCFG_EXT = %08X / %08X (val7 %08X)\n", SCFG_EXT[0], SCFG_EXT[1], val);
|
||||
return;
|
||||
case 0x04004010:
|
||||
if (!(SCFG_EXT[1] & (1 << 31))) /* no access to SCFG Registers if disabled*/
|
||||
@ -3071,7 +3073,7 @@ void ARM7IOWrite32(u32 addr, u32 val)
|
||||
case 0x04004408: DSi_AES::WriteInputFIFO(val); return;
|
||||
|
||||
case 0x4004700:
|
||||
printf("32-Bit SNDExCnt write? %08X %08X\n", val, NDS::ARM7->R[15]);
|
||||
Log(LogLevel::Debug, "32-Bit SNDExCnt write? %08X %08X\n", val, NDS::ARM7->R[15]);
|
||||
DSi_DSP::WriteSNDExCnt(val);
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user