Skip to content

Commit

Permalink
loggerex1 -> logger_en + removed unused loggerex0 macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo720 committed Mar 19, 2024
1 parent 7bbe8ef commit 11ee0dc
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 101 deletions.
26 changes: 13 additions & 13 deletions src/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ file_exists(std::pair<std::filesystem::path, std::string> 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;
Expand All @@ -80,10 +80,10 @@ file_exists(std::pair<std::filesystem::path, std::string> 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());
}
}

Expand All @@ -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;
Expand All @@ -120,18 +120,18 @@ 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;
}
}

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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/hw/cmos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -281,7 +281,7 @@ cmos::update_io(bool is_update)
.fnw8 = enable ? cpu_write<cmos, uint8_t, &cmos::write_handler_logger> : cpu_write<cmos, uint8_t, &cmos::write_handler>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update io ports");
logger_en(error, "Failed to update io ports");
return false;
}

Expand Down
24 changes: 12 additions & 12 deletions src/hw/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand All @@ -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<char[]> krnl_buff{ new char[static_cast<unsigned>(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);
Expand All @@ -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<PIMAGE_DOS_HEADER>(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;
}

Expand All @@ -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<pic>() }, "nboxkrnl"))) {
loggerex1(error, "Failed to create cpu instance");
logger_en(error, "Failed to create cpu instance");
return false;
}

Expand All @@ -124,17 +124,17 @@ cpu::init(const init_info_t &init_info)
cpu_set_flags(m_lc86cpu, static_cast<uint32_t>(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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/hw/pci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<uint8_t[]>(256)).get();
}
Expand Down Expand Up @@ -230,7 +230,7 @@ pci::update_io(bool is_update)
.fnw32 = enable ? cpu_write<pci, uint32_t, &pci::write32_logger> : cpu_write<pci, uint32_t, &pci::write32>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update io ports");
logger_en(error, "Failed to update io ports");
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions src/hw/pic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ pic::update_io(bool is_update)
.fnw8 = enable ? cpu_write<pic, uint8_t, &pic::write_handler_logger> : cpu_write<pic, uint8_t, &pic::write_handler>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update io ports");
logger_en(error, "Failed to update io ports");
return false;
}

Expand All @@ -334,7 +334,7 @@ pic::update_io(bool is_update)
.fnw8 = enable ? cpu_write<pic, uint8_t, &pic::elcr_write_handler_logger> : cpu_write<pic, uint8_t, &pic::elcr_write_handler>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update elcr io ports");
logger_en(error, "Failed to update elcr io ports");
return false;
}
}
Expand All @@ -345,7 +345,7 @@ pic::update_io(bool is_update)
.fnw8 = enable ? cpu_write<pic, uint8_t, &pic::write_handler_logger> : cpu_write<pic, uint8_t, &pic::write_handler>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update pic io ports");
logger_en(error, "Failed to update pic io ports");
return false;
}

Expand All @@ -355,7 +355,7 @@ pic::update_io(bool is_update)
.fnw8 = enable ? cpu_write<pic, uint8_t, &pic::elcr_write_handler_logger> : cpu_write<pic, uint8_t, &pic::elcr_write_handler>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update elcr io ports");
logger_en(error, "Failed to update elcr io ports");
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/hw/pit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pit::update_io(bool is_update)
.fnw8 = enable ? cpu_write<pit, uint8_t, &pit::write_handler_logger> : cpu_write<pit, uint8_t, &pit::write_handler>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update io ports");
logger_en(error, "Failed to update io ports");
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/hw/video/gpu/pbus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pbus::update_io(bool is_update)
.fnw32 = enable ? cpu_write<pbus, uint32_t, &pbus::write_logger> : cpu_write<pbus, uint32_t, &pbus::write>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand All @@ -195,7 +195,7 @@ pbus::update_io(bool is_update)
.fnw32 = enable ? cpu_write<pbus, uint32_t, &pbus::pci_write_logger> : cpu_write<pbus, uint32_t, &pbus::pci_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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hw/video/gpu/pcrtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pcrtc::update_io(bool is_update)
.fnw32 = enable ? cpu_write<pcrtc, uint32_t, &pcrtc::write_logger> : cpu_write<pcrtc, uint32_t, &pcrtc::write>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hw/video/gpu/pfb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pfb::update_io(bool is_update)
.fnw32 = enable ? cpu_write<pfb, uint32_t, &pfb::write_logger> : cpu_write<pfb, uint32_t, &pfb::write>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hw/video/gpu/pfifo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pfifo::update_io(bool is_update)
.fnw32 = enable ? cpu_write<pfifo, uint32_t, &pfifo::write_logger> : cpu_write<pfifo, uint32_t, &pfifo::write>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hw/video/gpu/pmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pmc::update_io(bool is_update)
.fnw32 = enable ? cpu_write<pmc, uint32_t, &pmc::write_logger> : cpu_write<pmc, uint32_t, &pmc::write>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hw/video/gpu/pramdac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pramdac::update_io(bool is_update)
.fnw32 = enable ? cpu_write<pramdac, uint32_t, &pramdac::write32_logger> : cpu_write<pramdac, uint32_t, &pramdac::write32>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hw/video/gpu/pramin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pramin::update_io(bool is_update)
.fnw32 = enable ? cpu_write<pramin, uint32_t, &pramin::write32_logger> : cpu_write<pramin, uint32_t, &pramin::write32>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hw/video/gpu/ptimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ ptimer::update_io(bool is_update)
.fnw32 = enable ? cpu_write<ptimer, uint32_t, &ptimer::write_logger> : cpu_write<ptimer, uint32_t, &ptimer::write>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions src/hw/video/gpu/pvga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pvga::update_io(bool is_update)
.fnw16 = enable ? cpu_write<pvga, uint16_t, &pvga::io_write16_logger, NV_PRMVIO_BASE> : cpu_write<pvga, uint16_t, &pvga::io_write16, NV_PRMVIO_BASE>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand All @@ -137,7 +137,7 @@ pvga::update_io(bool is_update)
.fnw16 = enable ? cpu_write<pvga, uint16_t, &pvga::io_write16_logger, NV_PRMCIO_BASE> : cpu_write<pvga, uint16_t, &pvga::io_write16, NV_PRMCIO_BASE>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand All @@ -149,7 +149,7 @@ pvga::update_io(bool is_update)
.fnw16 = enable ? cpu_write<pvga, uint16_t, &pvga::io_write16_logger, NV_PRMDIO_BASE> : cpu_write<pvga, uint16_t, &pvga::io_write16, NV_PRMDIO_BASE>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand All @@ -162,7 +162,7 @@ pvga::update_io(bool is_update)
.fnw16 = enable ? cpu_write<pvga, uint16_t, &pvga::mem_write16_logger, NV_PRMVGA_BASE> : cpu_write<pvga, uint16_t, &pvga::mem_write16, NV_PRMVGA_BASE>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hw/video/gpu/pvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pvideo::update_io(bool is_update)
.fnw32 = enable ? cpu_write<pvideo, uint32_t, &pvideo::write_logger> : cpu_write<pvideo, uint32_t, &pvideo::write>
},
this, is_update, is_update))) {
loggerex1(error, "Failed to update mmio region");
logger_en(error, "Failed to update mmio region");
return false;
}

Expand Down
Loading

0 comments on commit 11ee0dc

Please sign in to comment.