From baef838f7c1ba3f8780df922f29e63ec47556f5b Mon Sep 17 00:00:00 2001 From: dingusdev Date: Mon, 24 Feb 2020 07:54:29 -0700 Subject: [PATCH] Further integration with loguru --- cpu/ppc/ppcexec.cpp | 9 +++++---- devices/mpc106.cpp | 31 ++++++++++++++----------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/cpu/ppc/ppcexec.cpp b/cpu/ppc/ppcexec.cpp index 0264290..0f545f6 100644 --- a/cpu/ppc/ppcexec.cpp +++ b/cpu/ppc/ppcexec.cpp @@ -5,6 +5,7 @@ //if you want to distribute this. //(divingkatae#1017 or powermax#2286 on Discord) +#include #include #include #include @@ -416,21 +417,21 @@ static std::unordered_map SubOpcode63Grabber = { void ppc_illegalop() { uint8_t illegal_code = ppc_cur_instruction >> 26; uint32_t grab_it = (uint32_t)illegal_code; - printf("Illegal opcode reported: %d Report this! \n", grab_it); + LOG_F(ERROR, "Illegal opcode reported: %d Report this! \n", grab_it); exit(-1); } void ppc_illegalsubop31() { uint16_t illegal_subcode = ppc_cur_instruction & 2047; uint32_t grab_it = (uint32_t)illegal_subcode; - printf("Illegal subopcode for 31 reported: %d Report this! \n", grab_it); + LOG_F(ERROR, "Illegal subopcode for 31 reported: %d Report this! \n", grab_it); } void ppc_opcode4() { - printf("Reading from Opcode 4 table \n"); + LOG_F(INFO, "Reading from Opcode 4 table \n"); uint8_t subop_grab = ppc_cur_instruction & 3; uint32_t regrab = (uint32_t)subop_grab; - printf("Executing subopcode entry %d \n" + LOG_F(ERROR, "Executing subopcode entry %d \n" ".. or would if I bothered to implement it. SORRY!", regrab); exit(0); } diff --git a/devices/mpc106.cpp b/devices/mpc106.cpp index 74ff9e3..0c6d830 100644 --- a/devices/mpc106.cpp +++ b/devices/mpc106.cpp @@ -62,8 +62,8 @@ uint32_t MPC106::pci_read(uint32_t size) bus_num = (this->config_addr >> 8) & 0xFF; if (bus_num) { - std::cout << this->name << " err: read attempt from non-local PCI bus, " - << "config_addr = " << std::hex << this->config_addr << std::endl; + LOG_F(ERROR, "%s err: read attempt from non-local PCI bus, config_addr = %x \n", \ + this->name.c_str(), this->config_addr); return 0; } @@ -77,8 +77,7 @@ uint32_t MPC106::pci_read(uint32_t size) if (this->pci_0_bus.count(dev_num)) { return this->pci_0_bus[dev_num]->pci_cfg_read(reg_offs, size); } else { - std::cout << this->name << " err: read attempt from non-existing PCI device " - << dev_num << std::endl; + LOG_F(ERROR, "%s err: read attempt from non-existing PCI device %d \n", this->name.c_str(), dev_num); return 0; } } @@ -92,8 +91,8 @@ void MPC106::pci_write(uint32_t value, uint32_t size) bus_num = (this->config_addr >> 8) & 0xFF; if (bus_num) { - std::cout << this->name << " err: write attempt to non-local PCI bus, " - << "config_addr = " << std::hex << this->config_addr << std::endl; + LOG_F(ERROR, "%s err: write attempt to non-local PCI bus, config_addr = %x \n", + this->name.c_str(), this->config_addr); return; } @@ -107,8 +106,8 @@ void MPC106::pci_write(uint32_t value, uint32_t size) if (this->pci_0_bus.count(dev_num)) { this->pci_0_bus[dev_num]->pci_cfg_write(reg_offs, value, size); } else { - std::cout << this->name << " err: write attempt to non-existing PCI device " - << dev_num << std::endl; + LOG_F(ERROR, "%s err: write attempt to non-existing PCI device %d \n", \ + this->name.c_str(), dev_num); } } } @@ -116,7 +115,7 @@ void MPC106::pci_write(uint32_t value, uint32_t size) uint32_t MPC106::pci_cfg_read(uint32_t reg_offs, uint32_t size) { #ifdef MPC106_DEBUG - printf("read from Grackle register %08X\n", reg_offs); + LOG_F(INFO, "read from Grackle register %08X\n", reg_offs); #endif switch(size) { @@ -130,8 +129,7 @@ uint32_t MPC106::pci_cfg_read(uint32_t reg_offs, uint32_t size) return READ_DWORD_BE_A(&this->my_pci_cfg_hdr[reg_offs]); break; default: - std::cout << "MPC106 read error: invalid size parameter " << size - << std::endl; + LOG_F(ERROR, "MPC106 read error: invalid size parameter %d \n", size); } return 0; @@ -140,7 +138,7 @@ uint32_t MPC106::pci_cfg_read(uint32_t reg_offs, uint32_t size) void MPC106::pci_cfg_write(uint32_t reg_offs, uint32_t value, uint32_t size) { #ifdef MPC106_DEBUG - printf("write %08X to Grackle register %08X\n", value, reg_offs); + LOG_F(ERROR, "write %08X to Grackle register %08X\n", value, reg_offs); #endif // FIXME: implement write-protection for read-only registers @@ -159,13 +157,12 @@ void MPC106::pci_cfg_write(uint32_t reg_offs, uint32_t value, uint32_t size) this->my_pci_cfg_hdr[reg_offs+3] = value & 0xFF; break; default: - std::cout << "MPC106 read error: invalid size parameter " << size - << std::endl; + LOG_F(ERROR, "MPC106 read error: invalid size parameter %d \n", size); } if (this->my_pci_cfg_hdr[0xF2] & 8) { #ifdef MPC106_DEBUG - std::cout << "MPC106: MCCR1[MEMGO] was set! " << std::endl; + LOG_F(INFO, "MPC106: MCCR1[MEMGO] was set! \n"); #endif setup_ram(); } @@ -214,12 +211,12 @@ void MPC106::setup_ram() bank_end = (((ext_mem_end >> bank * 8) & 3) << 30) | (((mem_end >> bank * 8) & 0xFF) << 20) | 0xFFFFFUL; if (bank && bank_start != ram_size) - std::cout << "MPC106 error: RAM not contiguous!" << std::endl; + LOG_F(ERROR, "MPC106 error: RAM not contiguous! \n"); ram_size += bank_end + 1; } } if (!this->add_ram_region(0, ram_size)) { - std::cout << "MPC106 RAM allocation failed!" << std::endl; + LOG_F(ERROR, "MPC106 RAM allocation failed! \n"); } }