1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:27:35 +00:00

Kernel: Use klog() instead of kprintf()

Also, duplicate data in dbg() and klog() calls were removed.
In addition, leakage of virtual address to kernel log is prevented.
This is done by replacing kprintf() calls to dbg() calls with the
leaked data instead.
Also, other kprintf() calls were replaced with klog().
This commit is contained in:
Liav A 2020-03-01 21:45:39 +02:00 committed by Andreas Kling
parent 19aa53e1f9
commit 0fc60e41dd
53 changed files with 397 additions and 573 deletions

View file

@ -172,7 +172,7 @@ namespace APIC {
return false;
PhysicalAddress apic_base = get_base();
kprintf("Initializing APIC, base: P%x\n", apic_base);
klog() << "Initializing APIC, base: P " << String::format("%p", apic_base);
set_base(apic_base);
g_apic_base = apic_base.as_ptr();
@ -188,7 +188,7 @@ namespace APIC {
void enable(u32 cpu)
{
kprintf("Enabling local APIC for cpu #%u\n", cpu);
klog() << "Enabling local APIC for cpu #" << cpu;
// set spurious interrupt vector
write_register(APIC_REG_SIV, read_register(APIC_REG_SIV) | 0x100);

View file

@ -51,9 +51,9 @@ IOAPIC::IOAPIC(ioapic_mmio_regs& regs, u32 gsi_base, Vector<RefPtr<ISAInterruptO
, m_isa_interrupt_overrides(isa_overrides)
, m_pci_interrupt_overrides(pci_overrides)
{
kprintf("IOAPIC ID: 0x%x\n", m_id);
kprintf("IOAPIC Version: 0x%x, Redirection Entries count - %u\n", m_version, m_redirection_entries);
kprintf("IOAPIC Arbitration ID 0x%x\n", read_register(0x2));
klog() << "IOAPIC ID: 0x" << String::format("%x", m_id);
klog() << "IOAPIC Version: 0x" << String::format("%x", m_version) << ", Redirection Entries count - " << m_redirection_entries;
klog() << "IOAPIC Arbitration ID 0x" << String::format("%x", read_register(0x2));
mask_all_redirection_entries();
}

View file

@ -109,7 +109,7 @@ InterruptManagement::InterruptManagement()
void InterruptManagement::switch_to_pic_mode()
{
kprintf("Interrupts: Switch to Legacy PIC mode\n");
klog() << "Interrupts: Switch to Legacy PIC mode";
SpuriousInterruptHandler::initialize(7);
SpuriousInterruptHandler::initialize(15);
for (auto& irq_controller : m_interrupt_controllers) {
@ -125,10 +125,10 @@ void InterruptManagement::switch_to_pic_mode()
void InterruptManagement::switch_to_ioapic_mode()
{
kprintf("Interrupts: Switch to IOAPIC mode\n");
klog() << "Interrupts: Switch to IOAPIC mode";
if (m_interrupt_controllers.size() == 1) {
if (get_interrupt_controller(0).type() == IRQControllerType::i8259) {
kprintf("Interrupts: NO IOAPIC detected, Reverting to PIC mode.\n");
klog() << "Interrupts: NO IOAPIC detected, Reverting to PIC mode.";
return;
}
}

View file

@ -190,7 +190,7 @@ void PIC::initialize()
// ...except IRQ2, since that's needed for the master to let through slave interrupts.
enable(2);
kprintf("PIC(i8259): cascading mode, vectors 0x%b-0x%b\n", IRQ_VECTOR_BASE, IRQ_VECTOR_BASE + 0xf);
klog() << "PIC(i8259): cascading mode, vectors 0x" << String::format("%x", IRQ_VECTOR_BASE) << "-0x" << String::format("%x", IRQ_VECTOR_BASE + 0xf);
}
u16 PIC::get_isr() const

View file

@ -42,7 +42,7 @@ void SharedIRQHandler::initialize(u8 interrupt_number)
void SharedIRQHandler::register_handler(GenericInterruptHandler& handler)
{
#ifdef INTERRUPT_DEBUG
kprintf("Interrupt Handler registered @ Shared Interrupt Handler %d\n", m_interrupt_number);
klog() << "Interrupt Handler registered @ Shared Interrupt Handler " << m_interrupt_number;
#endif
m_handlers.set(&handler);
enable_interrupt_vector();
@ -50,7 +50,7 @@ void SharedIRQHandler::register_handler(GenericInterruptHandler& handler)
void SharedIRQHandler::unregister_handler(GenericInterruptHandler& handler)
{
#ifdef INTERRUPT_DEBUG
kprintf("Interrupt Handler unregistered @ Shared Interrupt Handler %d\n", m_interrupt_number);
klog() << "Interrupt Handler unregistered @ Shared Interrupt Handler " << m_interrupt_number;
#endif
m_handlers.remove(&handler);
if (m_handlers.is_empty())
@ -71,7 +71,7 @@ SharedIRQHandler::SharedIRQHandler(u8 irq)
, m_responsible_irq_controller(InterruptManagement::the().get_responsible_irq_controller(irq))
{
#ifdef INTERRUPT_DEBUG
kprintf("Shared Interrupt Handler registered @ %d\n", m_interrupt_number);
klog() << "Shared Interrupt Handler registered @ " << m_interrupt_number;
#endif
disable_interrupt_vector();
}
@ -79,7 +79,7 @@ SharedIRQHandler::SharedIRQHandler(u8 irq)
SharedIRQHandler::~SharedIRQHandler()
{
#ifdef INTERRUPT_DEBUG
kprintf("Shared Interrupt Handler unregistered @ %d\n", interrupt_number());
klog() << "Shared Interrupt Handler unregistered @ " << interrupt_number();
#endif
disable_interrupt_vector();
}

View file

@ -62,7 +62,7 @@ SpuriousInterruptHandler::~SpuriousInterruptHandler()
void SpuriousInterruptHandler::handle_interrupt(RegisterState&)
{
// FIXME: Actually check if IRQ7 or IRQ15 are spurious, and if not, call the real handler to handle the IRQ.
kprintf("Spurious Interrupt, vector %d\n", interrupt_number());
klog() << "Spurious Interrupt, vector " << interrupt_number();
}
void SpuriousInterruptHandler::enable_interrupt_vector()