diff --git a/src/files.cpp b/src/files.cpp index 46e5b42..aee8393 100755 --- a/src/files.cpp +++ b/src/files.cpp @@ -62,10 +62,10 @@ file_exists(std::pair path_to_check, std::fi return true; } catch (const std::filesystem::filesystem_error &e) { - loggerex1(info, "Failed to check existence of path %s, the error was %s", resolved_path.string().c_str(), e.what()); + logger_en(info, "Failed to check existence of path %s, the error was %s", resolved_path.string().c_str(), e.what()); } catch (const std::bad_alloc &e) { - loggerex1(info, "Failed to check existence of path %s, the error was %s", resolved_path.string().c_str(), e.what()); + logger_en(info, "Failed to check existence of path %s, the error was %s", resolved_path.string().c_str(), e.what()); } return false; @@ -80,10 +80,10 @@ file_exists(std::pair path_to_check, std::fi return true; } catch (const std::filesystem::filesystem_error &e) { - loggerex1(info, "Failed to determine the file type of path %s, the error was %s", resolved_path.string().c_str(), e.what()); + logger_en(info, "Failed to determine the file type of path %s, the error was %s", resolved_path.string().c_str(), e.what()); } catch (const std::bad_alloc &e) { - loggerex1(info, "Failed to determine the file type of path %s, the error was %s", resolved_path.string().c_str(), e.what()); + logger_en(info, "Failed to determine the file type of path %s, the error was %s", resolved_path.string().c_str(), e.what()); } } @@ -97,10 +97,10 @@ file_exists(std::filesystem::path path) return std::filesystem::exists(path); } catch (const std::filesystem::filesystem_error &e) { - loggerex1(info, "Failed to determine the file type of path %s, the error was %s", path.string().c_str(), e.what()); + logger_en(info, "Failed to determine the file type of path %s, the error was %s", path.string().c_str(), e.what()); } catch (const std::bad_alloc &e) { - loggerex1(info, "Failed to determine the file type of path %s, the error was %s", path.string().c_str(), e.what()); + logger_en(info, "Failed to determine the file type of path %s, the error was %s", path.string().c_str(), e.what()); } return false; @@ -120,7 +120,7 @@ create_directory(std::filesystem::path path) if (!exists) { exists = std::filesystem::create_directories(path); if (!exists) { - loggerex1(info, "Failed to created directory %s", path.string().c_str()); + logger_en(info, "Failed to created directory %s", path.string().c_str()); return false; } } @@ -128,10 +128,10 @@ create_directory(std::filesystem::path path) return true; } catch (const std::filesystem::filesystem_error &e) { - loggerex1(info, "Failed to created directory %s, the error was %s", path.string().c_str(), e.what()); + logger_en(info, "Failed to created directory %s, the error was %s", path.string().c_str(), e.what()); } catch (const std::bad_alloc &e) { - loggerex1(info, "Failed to created directory %s, the error was %s", path.string().c_str(), e.what()); + logger_en(info, "Failed to created directory %s, the error was %s", path.string().c_str(), e.what()); } return false; @@ -154,10 +154,10 @@ create_file(std::filesystem::path path, uint64_t initial_size) std::filesystem::resize_file(path, initial_size); } catch (const std::filesystem::filesystem_error &e) { - loggerex1(info, "Failed to set the initial file size of path %s, the error was %s", path.string().c_str(), e.what()); + logger_en(info, "Failed to set the initial file size of path %s, the error was %s", path.string().c_str(), e.what()); } catch (const std::bad_alloc &e) { - loggerex1(info, "Failed to set the initial file size of path %s, the error was %s", path.string().c_str(), e.what()); + logger_en(info, "Failed to set the initial file size of path %s, the error was %s", path.string().c_str(), e.what()); } } return opt; @@ -181,11 +181,11 @@ open_file(std::filesystem::path path, std::uintmax_t *size) } catch (const std::filesystem::filesystem_error &e) { *size = 0; - loggerex1(info, "Failed to determine the file size of path %s, the error was %s", path.string().c_str(), e.what()); + logger_en(info, "Failed to determine the file size of path %s, the error was %s", path.string().c_str(), e.what()); } catch (const std::bad_alloc &e) { *size = 0; - loggerex1(info, "Failed to determine the file size of path %s, the error was %s", path.string().c_str(), e.what()); + logger_en(info, "Failed to determine the file size of path %s, the error was %s", path.string().c_str(), e.what()); } return opt; } diff --git a/src/hw/cmos.cpp b/src/hw/cmos.cpp index 76cba4b..df3e4c6 100644 --- a/src/hw/cmos.cpp +++ b/src/hw/cmos.cpp @@ -224,7 +224,7 @@ cmos::write_handler(uint32_t addr, const uint8_t data) default: if (reg_idx >= sizeof(ram)) { - loggerex1(warn, "CMOS write: unknown register %u", reg_idx); + logger_en(warn, "CMOS write: unknown register %u", reg_idx); return; } } @@ -281,7 +281,7 @@ cmos::update_io(bool is_update) .fnw8 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update io ports"); + logger_en(error, "Failed to update io ports"); return false; } diff --git a/src/hw/cpu.cpp b/src/hw/cpu.cpp index 2c8b04a..4ec4592 100644 --- a/src/hw/cpu.cpp +++ b/src/hw/cpu.cpp @@ -46,7 +46,7 @@ cpu::update_io(bool is_update) .fnr32 = enable ? kernel::read_handler_logger : kernel::read_handler, .fnw32 = enable ? kernel::write_handler_logger : kernel::write_handler }, m_lc86cpu, is_update, is_update))) { - loggerex1(error, "Failed to update kernel communication io ports"); + logger_en(error, "Failed to update kernel communication io ports"); return false; } @@ -67,7 +67,7 @@ cpu::init(const init_info_t &init_info) // Load the nboxkrnl exe file std::ifstream ifs(init_info.m_kernel.c_str(), std::ios_base::in | std::ios_base::binary); if (!ifs.is_open()) { - loggerex1(error, "Could not open kernel file"); + logger_en(error, "Could not open kernel file"); return false; } ifs.seekg(0, ifs.end); @@ -76,17 +76,17 @@ cpu::init(const init_info_t &init_info) // Sanity checks on the kernel exe size if (length == 0) { - loggerex1(error, "Size of kernel file detected as zero"); + logger_en(error, "Size of kernel file detected as zero"); return false; } else if (length > m_ramsize) { - loggerex1(error, "Kernel file doesn't fit inside ram"); + logger_en(error, "Kernel file doesn't fit inside ram"); return false; } std::unique_ptr krnl_buff{ new char[static_cast(length)] }; if (!krnl_buff) { - loggerex1(error, "Could not allocate kernel buffer"); + logger_en(error, "Could not allocate kernel buffer"); return false; } ifs.read(krnl_buff.get(), length); @@ -95,7 +95,7 @@ cpu::init(const init_info_t &init_info) // Sanity checks on the kernel exe file PIMAGE_DOS_HEADER dosHeader = reinterpret_cast(krnl_buff.get()); if (dosHeader->e_magic != IMAGE_DOS_SIGNATURE) { - loggerex1(error, "Kernel image has an invalid dos header signature"); + logger_en(error, "Kernel image has an invalid dos header signature"); return false; } @@ -104,18 +104,18 @@ cpu::init(const init_info_t &init_info) peHeader->FileHeader.Machine != IMAGE_FILE_MACHINE_I386 || peHeader->OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC || peHeader->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_NATIVE) { - loggerex1(error, "Kernel image has an invalid nt header signature"); + logger_en(error, "Kernel image has an invalid nt header signature"); return false; } if (peHeader->OptionalHeader.ImageBase != KERNEL_BASE) { - loggerex1(error, "Kernel image has an incorrect image base address"); + logger_en(error, "Kernel image has an incorrect image base address"); return false; } // Init lib86cpu if (!LC86_SUCCESS(cpu_new(m_ramsize, m_lc86cpu, { get_interrupt_for_cpu, &m_machine->get() }, "nboxkrnl"))) { - loggerex1(error, "Failed to create cpu instance"); + logger_en(error, "Failed to create cpu instance"); return false; } @@ -124,17 +124,17 @@ cpu::init(const init_info_t &init_info) cpu_set_flags(m_lc86cpu, static_cast(init_info.m_syntax) | (init_info.m_use_dbg ? CPU_DBG_PRESENT : 0)); if (!LC86_SUCCESS(mem_init_region_ram(m_lc86cpu, 0, m_ramsize))) { - loggerex1(error, "Failed to initialize ram memory"); + logger_en(error, "Failed to initialize ram memory"); return false; } if (!LC86_SUCCESS(mem_init_region_alias(m_lc86cpu, CONTIGUOUS_MEMORY_BASE, 0, m_ramsize))) { - loggerex1(error, "Failed to initialize contiguous memory"); + logger_en(error, "Failed to initialize contiguous memory"); return false; } if (!LC86_SUCCESS(mem_init_region_alias(m_lc86cpu, NV2A_VRAM_BASE, 0, m_ramsize))) { - loggerex1(error, "Failed to initialize vram memory for nv2a"); + logger_en(error, "Failed to initialize vram memory for nv2a"); return false; } diff --git a/src/hw/pci.cpp b/src/hw/pci.cpp index 92ddf84..9749d2b 100644 --- a/src/hw/pci.cpp +++ b/src/hw/pci.cpp @@ -23,7 +23,7 @@ pci::write8(uint32_t addr, const uint8_t data) configuration_address_register |= data << offset; if (configuration_address_register & 0x7F000003) { - loggerex1(info, "Setting reserved bits of configuration address register"); + logger_en(info, "Setting reserved bits of configuration address register"); } configuration_address_register &= ~0x7F000003; configuration_cycle = configuration_address_register >> 31; @@ -186,7 +186,7 @@ pci::create_device(uint32_t bus, uint32_t device, uint32_t function, pci_conf_wr int bdf = (bus << 8) | (device << 3) | function; configuration_modification.emplace(bdf, std::make_pair(cb, opaque)); - loggerex1(info, "Registering device at bus=%" PRIu32 " device=%" PRIu32 " function=%" PRIu32, bus, device, function); + logger_en(info, "Registering device at bus=%" PRIu32 " device=%" PRIu32 " function=%" PRIu32, bus, device, function); return (configuration_address_spaces[bdf] = std::make_unique(256)).get(); } @@ -230,7 +230,7 @@ pci::update_io(bool is_update) .fnw32 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update io ports"); + logger_en(error, "Failed to update io ports"); return false; } diff --git a/src/hw/pic.cpp b/src/hw/pic.cpp index 5db7453..9ee612b 100644 --- a/src/hw/pic.cpp +++ b/src/hw/pic.cpp @@ -324,7 +324,7 @@ pic::update_io(bool is_update) .fnw8 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update io ports"); + logger_en(error, "Failed to update io ports"); return false; } @@ -334,7 +334,7 @@ pic::update_io(bool is_update) .fnw8 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update elcr io ports"); + logger_en(error, "Failed to update elcr io ports"); return false; } } @@ -345,7 +345,7 @@ pic::update_io(bool is_update) .fnw8 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update pic io ports"); + logger_en(error, "Failed to update pic io ports"); return false; } @@ -355,7 +355,7 @@ pic::update_io(bool is_update) .fnw8 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update elcr io ports"); + logger_en(error, "Failed to update elcr io ports"); return false; } } diff --git a/src/hw/pit.cpp b/src/hw/pit.cpp index c0cf168..45fceca 100644 --- a/src/hw/pit.cpp +++ b/src/hw/pit.cpp @@ -146,7 +146,7 @@ pit::update_io(bool is_update) .fnw8 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update io ports"); + logger_en(error, "Failed to update io ports"); return false; } diff --git a/src/hw/video/gpu/pbus.cpp b/src/hw/video/gpu/pbus.cpp index 6cb1af8..8500bd9 100644 --- a/src/hw/video/gpu/pbus.cpp +++ b/src/hw/video/gpu/pbus.cpp @@ -185,7 +185,7 @@ pbus::update_io(bool is_update) .fnw32 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } @@ -195,7 +195,7 @@ pbus::update_io(bool is_update) .fnw32 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update pci mmio region"); + logger_en(error, "Failed to update pci mmio region"); return false; } diff --git a/src/hw/video/gpu/pcrtc.cpp b/src/hw/video/gpu/pcrtc.cpp index 79a2c94..971cace 100644 --- a/src/hw/video/gpu/pcrtc.cpp +++ b/src/hw/video/gpu/pcrtc.cpp @@ -100,7 +100,7 @@ pcrtc::update_io(bool is_update) .fnw32 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } diff --git a/src/hw/video/gpu/pfb.cpp b/src/hw/video/gpu/pfb.cpp index 0394d18..c9c6f9a 100644 --- a/src/hw/video/gpu/pfb.cpp +++ b/src/hw/video/gpu/pfb.cpp @@ -97,7 +97,7 @@ pfb::update_io(bool is_update) .fnw32 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } diff --git a/src/hw/video/gpu/pfifo.cpp b/src/hw/video/gpu/pfifo.cpp index 325a87f..54a6c05 100644 --- a/src/hw/video/gpu/pfifo.cpp +++ b/src/hw/video/gpu/pfifo.cpp @@ -88,7 +88,7 @@ pfifo::update_io(bool is_update) .fnw32 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } diff --git a/src/hw/video/gpu/pmc.cpp b/src/hw/video/gpu/pmc.cpp index 5639c68..124a09c 100644 --- a/src/hw/video/gpu/pmc.cpp +++ b/src/hw/video/gpu/pmc.cpp @@ -202,7 +202,7 @@ pmc::update_io(bool is_update) .fnw32 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } diff --git a/src/hw/video/gpu/pramdac.cpp b/src/hw/video/gpu/pramdac.cpp index d47d1be..2e7696b 100644 --- a/src/hw/video/gpu/pramdac.cpp +++ b/src/hw/video/gpu/pramdac.cpp @@ -123,7 +123,7 @@ pramdac::update_io(bool is_update) .fnw32 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } diff --git a/src/hw/video/gpu/pramin.cpp b/src/hw/video/gpu/pramin.cpp index 1cc69de..4ecae90 100644 --- a/src/hw/video/gpu/pramin.cpp +++ b/src/hw/video/gpu/pramin.cpp @@ -119,7 +119,7 @@ pramin::update_io(bool is_update) .fnw32 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } diff --git a/src/hw/video/gpu/ptimer.cpp b/src/hw/video/gpu/ptimer.cpp index c83b439..7719e01 100644 --- a/src/hw/video/gpu/ptimer.cpp +++ b/src/hw/video/gpu/ptimer.cpp @@ -214,7 +214,7 @@ ptimer::update_io(bool is_update) .fnw32 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } diff --git a/src/hw/video/gpu/pvga.cpp b/src/hw/video/gpu/pvga.cpp index cd9e71a..f6efc9f 100644 --- a/src/hw/video/gpu/pvga.cpp +++ b/src/hw/video/gpu/pvga.cpp @@ -125,7 +125,7 @@ pvga::update_io(bool is_update) .fnw16 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } @@ -137,7 +137,7 @@ pvga::update_io(bool is_update) .fnw16 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } @@ -149,7 +149,7 @@ pvga::update_io(bool is_update) .fnw16 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } @@ -162,7 +162,7 @@ pvga::update_io(bool is_update) .fnw16 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } diff --git a/src/hw/video/gpu/pvideo.cpp b/src/hw/video/gpu/pvideo.cpp index 08339bf..f172b1e 100644 --- a/src/hw/video/gpu/pvideo.cpp +++ b/src/hw/video/gpu/pvideo.cpp @@ -100,7 +100,7 @@ pvideo::update_io(bool is_update) .fnw32 = enable ? cpu_write : cpu_write }, this, is_update, is_update))) { - loggerex1(error, "Failed to update mmio region"); + logger_en(error, "Failed to update mmio region"); return false; } diff --git a/src/hw/video/vga.cpp b/src/hw/video/vga.cpp index cc88c7a..0e8d5f0 100644 --- a/src/hw/video/vga.cpp +++ b/src/hw/video/vga.cpp @@ -175,7 +175,7 @@ vga::update_mem_access() } write_mode = gfx[5] & 3; - loggerex1(debug, "Updating Memory Access Constants: write=%" PRIu8 " [mode=%" PRIu8 "], read=%" PRIu8, write_access, write_mode, read_access); + logger_en(debug, "Updating Memory Access Constants: write=%" PRIu8 " [mode=%" PRIu8 "], read=%" PRIu8, write_access, write_mode, read_access); } void @@ -225,7 +225,7 @@ vga::change_renderer() else { renderer = BLANK_RENDERER; } - loggerex1(debug, "Change renderer to: %" PRId32, renderer); + logger_en(debug, "Change renderer to: %" PRId32, renderer); renderer |= (seq[1] >> 3 & 1); complete_redraw(); } @@ -264,7 +264,7 @@ void vga::io_write8(uint32_t addr, const uint8_t data) { if ((addr >= 0x3B0 && addr <= 0x3BF && (misc & 1)) || (addr >= 0x3D0 && addr <= 0x3DF && !(misc & 1))) { - loggerex1(warn, "Ignoring unsupported write to addr=%04" PRIX32 " data=%02" PRIX8 " misc=%02" PRIX8, addr, data, misc); + logger_en(warn, "Ignoring unsupported write to addr=%04" PRIX32 " data=%02" PRIX8 " misc=%02" PRIX8, addr, data, misc); return; } @@ -345,15 +345,15 @@ bit 0 Graphics mode if set, Alphanumeric mode else. ) { complete_redraw(); } - loggerex1(debug, "Mode Control Register: %02" PRIX8, data); + logger_en(debug, "Mode Control Register: %02" PRIX8, data); break; case 17: // Overscan color register break; - loggerex1(debug, "Overscan color (currently unused): %02" PRIX8, data); + logger_en(debug, "Overscan color (currently unused): %02" PRIX8, data); break; case 18: // Color Plane Enable - loggerex1(debug, "Color plane enable: %02" PRIX8, data); + logger_en(debug, "Color plane enable: %02" PRIX8, data); attr[18] &= 0x0F; break; @@ -383,11 +383,11 @@ bit 0 Graphics mode if set, Alphanumeric mode else. else { pixel_panning = (data & 7) + (char_width & 1); } - loggerex1(debug, "Pixel panning: %" PRIX8 " [raw], %" PRIX8 " [effective value]", data, pixel_panning); + logger_en(debug, "Pixel panning: %" PRIX8 " [raw], %" PRIX8 " [effective value]", data, pixel_panning); break; case 20: // Color Select Register - loggerex1(debug, "Color select register: %02" PRIX8, data); + logger_en(debug, "Color select register: %02" PRIX8, data); if (diffxor & 15) { for (int i = 0; i < 16; i++) { change_attr_cache(i); @@ -401,7 +401,7 @@ bit 0 Graphics mode if set, Alphanumeric mode else. break; case 0x3C2: // Miscellaneous Output Register - loggerex1(debug, "Write VGA miscellaneous register: 0x%02" PRIX8, data); + logger_en(debug, "Write VGA miscellaneous register: 0x%02" PRIX8, data); /* bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base Address=3Bxh. @@ -429,7 +429,7 @@ bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base case 0x3DA: case 0x3D8: case 0x3CD: - loggerex1(warn, "Unknown write to %x: %02" PRIX8, addr, data); + logger_en(warn, "Unknown write to %x: %02" PRIX8, addr, data); break; case 0x3C4: // Sequencer Index @@ -455,11 +455,11 @@ bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base switch (seq_index) { case 0: // Sequencer Reset - loggerex1(debug, "SEQ: Resetting sequencer"); + logger_en(debug, "SEQ: Resetting sequencer"); break; case 1: // Clocking Mode - loggerex1(debug, "SEQ: Setting Clocking Mode to 0x%02" PRIX8, data1); + logger_en(debug, "SEQ: Setting Clocking Mode to 0x%02" PRIX8, data1); if (diffxor & 0x20) { // Screen Off change_renderer(); } @@ -475,18 +475,18 @@ bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base break; case 2: // Memory Write Access - loggerex1(debug, "SEQ: Memory plane write access: 0x%02" PRIX8, data1); + logger_en(debug, "SEQ: Memory plane write access: 0x%02" PRIX8, data1); break; case 3: // Character Map Select // Note these are font addresses in plane 2 - loggerex1(debug, "SEQ: Memory plane write access: 0x%02" PRIX8, data1); + logger_en(debug, "SEQ: Memory plane write access: 0x%02" PRIX8, data1); character_map[0] = char_map_address((data1 >> 5 & 1) | (data1 >> 1 & 6)); character_map[1] = char_map_address((data1 >> 4 & 1) | (data1 << 1 & 6)); break; case 4: // Memory Mode - loggerex1(debug, "SEQ: Memory Mode: 0x%02" PRIX8, data1); + logger_en(debug, "SEQ: Memory Mode: 0x%02" PRIX8, data1); if (diffxor & 0b1100) { update_mem_access(); } @@ -554,27 +554,27 @@ bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base switch (gfx_index) { case 0: // Set/Reset Plane - loggerex1(debug, "Set/Reset Plane: %02" PRIX8, data1); + logger_en(debug, "Set/Reset Plane: %02" PRIX8, data1); break; case 1: // Enable Set/Reset Plane - loggerex1(debug, "Enable Set/Reset Plane: %02" PRIX8, data1); + logger_en(debug, "Enable Set/Reset Plane: %02" PRIX8, data1); break; case 2: // Color Comare - loggerex1(debug, "Color Compare: %02" PRIX8, data1); + logger_en(debug, "Color Compare: %02" PRIX8, data1); break; case 3: // Data Rotate/ALU Operation Select - loggerex1(debug, "Data Rotate: %02" PRIX8, data1); + logger_en(debug, "Data Rotate: %02" PRIX8, data1); break; case 4: // Read Plane Select - loggerex1(debug, "Read Plane Select: %02" PRIX8, data1); + logger_en(debug, "Read Plane Select: %02" PRIX8, data1); break; case 5: // Graphics Mode - loggerex1(debug, "Graphics Mode: %02" PRIX8, data1); + logger_en(debug, "Graphics Mode: %02" PRIX8, data1); if (diffxor & (3 << 5)) { // Shift Register Control change_renderer(); } @@ -584,7 +584,7 @@ bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base break; case 6: // Miscellaneous Register - loggerex1(debug, "Miscellaneous Register: %02" PRIX8, data); + logger_en(debug, "Miscellaneous Register: %02" PRIX8, data); switch (data >> 2 & 3) { case 0: @@ -613,11 +613,11 @@ bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base break; case 7: - loggerex1(debug, "Color Don't Care: %02" PRIX8, data1); + logger_en(debug, "Color Don't Care: %02" PRIX8, data1); break; case 8: - loggerex1(debug, "Bit Mask Register: %02" PRIX8, data1); + logger_en(debug, "Bit Mask Register: %02" PRIX8, data1); break; } } @@ -692,22 +692,22 @@ bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base switch (crt_index) { case 1: - loggerex1(debug, "End Horizontal Display: %02" PRIX8, data1); + logger_en(debug, "End Horizontal Display: %02" PRIX8, data1); update_size(); break; case 2: - loggerex1(debug, "Start Horizontal Blanking: %02" PRIX8, data1); + logger_en(debug, "Start Horizontal Blanking: %02" PRIX8, data1); update_size(); break; case 7: - loggerex1(debug, "CRT Overflow: %02" PRIX8, data1); + logger_en(debug, "CRT Overflow: %02" PRIX8, data1); update_size(); break; case 9: - loggerex1(debug, "Start Horizontal Blanking: %02" PRIX8, data1); + logger_en(debug, "Start Horizontal Blanking: %02" PRIX8, data1); if (diffxor & 0x20) { update_size(); } @@ -725,12 +725,12 @@ bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base break; case 0x12: - loggerex1(debug, "Vertical Display End: %02" PRIX8, data1); + logger_en(debug, "Vertical Display End: %02" PRIX8, data1); update_size(); break; case 0x15: - loggerex1(debug, "Start Vertical Blanking: %02" PRIX8, data1); + logger_en(debug, "Start Vertical Blanking: %02" PRIX8, data1); update_size(); break; } @@ -738,7 +738,7 @@ bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base break; } default: - loggerex1(warn, "VGA write: 0x%08" PRIX32 " [data: 0x%02" PRIX8 "]", addr, data); + logger_en(warn, "VGA write: 0x%08" PRIX32 " [data: 0x%02" PRIX8 "]", addr, data); } } @@ -822,7 +822,7 @@ vga::io_read8(uint32_t addr) return crt[crt_index]; default: - loggerex1(warn, "Unknown read: 0x%" PRIX32, addr); + logger_en(warn, "Unknown read: 0x%" PRIX32, addr); return -1; } } diff --git a/src/io.cpp b/src/io.cpp index 911b98a..2a7fac2 100755 --- a/src/io.cpp +++ b/src/io.cpp @@ -276,7 +276,7 @@ namespace io { const auto add_to_map = [&curr_io_request, dev](auto &&opt, io_info_block *io_result, std::filesystem::path resolved_path) { // NOTE: this insertion will fail when the guest creates a new handle to the same file. This, because it will pass the same host handle, and std::unordered_map // doesn't allow duplicated keys. This is ok though, because we can reuse the same std::fstream for the same file and it will have the same path too - loggerex1(info, "Opened %s with handle %" PRIu64 " and path %s", opt->is_open() ? "file" : "directory", curr_io_request->handle_oc, resolved_path.string().c_str()); + logger_en(info, "Opened %s with handle %" PRIu64 " and path %s", opt->is_open() ? "file" : "directory", curr_io_request->handle_oc, resolved_path.string().c_str()); auto pair = xbox_handle_map[dev].emplace(curr_io_request->handle_oc, std::make_pair(std::move(*opt), resolved_path.string())); io_result->status = success; }; @@ -380,7 +380,7 @@ namespace io { io_info_block io_result(success, no_data); auto it = xbox_handle_map[dev].find(curr_io_request->handle); if (it == xbox_handle_map[dev].end()) [[unlikely]] { - loggerex1(warn, "Handle %" PRIu64 " not found", curr_io_request->handle); // this should not happen... + logger_en(warn, "Handle %" PRIu64 " not found", curr_io_request->handle); // this should not happen... io_result.status = error; completed_io_mtx.lock(); completed_io_info.emplace(curr_io_request->id, std::move(curr_io_request)); @@ -392,14 +392,14 @@ namespace io { switch (io_type) { case io_request_type::close: - loggerex1(info, "Closed file handle %" PRIu64 " with path %s", it->first, it->second.second.c_str()); + logger_en(info, "Closed file handle %" PRIu64 " with path %s", it->first, it->second.second.c_str()); xbox_handle_map[dev].erase(it); break; case io_request_type::read: if (!fs->is_open()) [[unlikely]] { // Read operation on a directory (this should not happen...) - loggerex1(warn, "Read operation to directory handle %" PRIu64 " with path %s", it->first, it->second.second.c_str()); + logger_en(warn, "Read operation to directory handle %" PRIu64 " with path %s", it->first, it->second.second.c_str()); io_result.status = error; io_result.info = no_data; break; @@ -409,13 +409,13 @@ namespace io { fs->read(curr_io_request->io_buffer.get(), curr_io_request->size); if (fs->good()) { io_result.info = static_cast(fs->gcount()); - loggerex1(info, "Read operation to file handle %" PRIu64 ", offset=0x%08" PRIX32 ", size=0x%08" PRIX32 ", actual bytes transferred=0x%08" PRIX32 " -> OK!", + logger_en(info, "Read operation to file handle %" PRIu64 ", offset=0x%08" PRIX32 ", size=0x%08" PRIX32 ", actual bytes transferred=0x%08" PRIX32 " -> OK!", it->first, curr_io_request->offset, curr_io_request->size, io_result.info); } else { io_result.status = error; fs->clear(); - loggerex1(info, "Read operation to file handle %" PRIu64 " with path %s, offset=0x%08" PRIX32 ", size=0x%08" PRIX32 " -> FAILED!", + logger_en(info, "Read operation to file handle %" PRIu64 " with path %s, offset=0x%08" PRIX32 ", size=0x%08" PRIX32 " -> FAILED!", it->first, it->second.second.c_str(), curr_io_request->offset, curr_io_request->size); } break; @@ -423,7 +423,7 @@ namespace io { case io_request_type::write: if (!fs->is_open()) [[unlikely]] { // Write operation on a directory (this should not happen...) - loggerex1(warn, "Write operation to directory handle %" PRIu64 " with path %s", it->first, it->second.second.c_str()); + logger_en(warn, "Write operation to directory handle %" PRIu64 " with path %s", it->first, it->second.second.c_str()); io_result.status = error; io_result.info = no_data; break; @@ -434,18 +434,18 @@ namespace io { io_result.status = error; io_result.info = no_data; fs->clear(); - loggerex1(info, "Write operation to file handle %" PRIu64 " with path %s, offset=0x%08" PRIX32 ", size=0x%08" PRIX32 " -> FAILED!", + logger_en(info, "Write operation to file handle %" PRIu64 " with path %s, offset=0x%08" PRIX32 ", size=0x%08" PRIX32 " -> FAILED!", it->first, it->second.second.c_str(), curr_io_request->offset, curr_io_request->size); } else { io_result.info = static_cast(curr_io_request->size); - loggerex1(info, "Write operation to file handle %" PRIu64 ", offset=0x%08" PRIX32 ", size=0x%08" PRIX32 " -> OK!", + logger_en(info, "Write operation to file handle %" PRIu64 ", offset=0x%08" PRIX32 ", size=0x%08" PRIX32 " -> OK!", it->first, curr_io_request->offset, curr_io_request->size); } break; case io_request_type::remove1: { - loggerex1(info, "Deleted %s with handle %" PRIu64, fs->is_open() ? "file" : "directory", it->first); + logger_en(info, "Deleted %s with handle %" PRIu64, fs->is_open() ? "file" : "directory", it->first); std::string file_path(it->second.second); xbox_handle_map[dev].erase(it); std::error_code ec; @@ -454,7 +454,7 @@ namespace io { break; default: - loggerex1(warn, "Unknown io request of type %" PRId32, curr_io_request->type); + logger_en(warn, "Unknown io request of type %" PRId32, curr_io_request->type); } curr_io_request->info = io_result; @@ -571,7 +571,7 @@ namespace io { } } if (!create_partition_metadata_file(curr_partition_dir, i)) { - loggerex1(error, "Failed to create partition metadata bin files"); + logger_en(error, "Failed to create partition metadata bin files"); return false; } } @@ -580,12 +580,12 @@ namespace io { eeprom_dir.make_preferred(); if (!file_exists(eeprom_dir)) { if (auto opt = create_file(eeprom_dir); !opt) { - loggerex1(error, "Failed to create eeprom file"); + logger_en(error, "Failed to create eeprom file"); return false; } else { if (!gen_eeprom(std::move(opt.value()))) { - loggerex1(error, "Failed to update eeprom file"); + logger_en(error, "Failed to update eeprom file"); return false; } } @@ -613,7 +613,7 @@ namespace io { } if (!open_special_files()) { - loggerex1(error, "Failed to open partition metadata bin files"); + logger_en(error, "Failed to open partition metadata bin files"); return false; } diff --git a/src/kernel.cpp b/src/kernel.cpp index f854158..13583ca 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -69,7 +69,7 @@ namespace kernel { return acpi_time >> 32; default: - loggerex1(warn, "%s: unexpected I/O read at port 0x%" PRIX16, __func__, addr); + logger_en(warn, "%s: unexpected I/O read at port 0x%" PRIX16, __func__, addr); } return 0; @@ -85,7 +85,7 @@ namespace kernel { // Also, they might not be contiguous in physical memory, so we use mem_read_block_virt to avoid issues with allocations spanning pages uint8_t buff[512]; mem_read_block_virt(static_cast(opaque), data, sizeof(buff), buff); - loggerex1(info, "%s", buff); + logger_en(info, "%s", buff); } break; @@ -110,7 +110,7 @@ namespace kernel { break; default: - loggerex1(warn, "unexpected io write at port 0x%" PRIX16, addr); + logger_en(warn, "unexpected io write at port 0x%" PRIX16, addr); } } diff --git a/src/logger.hpp b/src/logger.hpp index 71048ef..35c8037 100644 --- a/src/logger.hpp +++ b/src/logger.hpp @@ -11,8 +11,7 @@ #include #include -#define loggerex0(lv, msg, ...) do { logger(msg __VA_OPT__(,) __VA_ARGS__); } while(0) -#define loggerex1(lv, msg, ...) do { logger(msg __VA_OPT__(,) __VA_ARGS__); } while(0) +#define logger_en(lv, msg, ...) do { logger(msg __VA_OPT__(,) __VA_ARGS__); } while(0) #define logger_nxbx(lv, msg, ...) do { logger(msg __VA_OPT__(,) __VA_ARGS__); } while(0) #define log_io_read() do { logger("Read at address 0x%08X of value 0x%08X", addr, data); } while(0) #define log_io_write() do { logger("Write at address 0x%08X of value 0x%08X", addr, data); } while(0)