mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09: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:
parent
19aa53e1f9
commit
0fc60e41dd
Notes:
sideshowbarker
2024-07-19 08:55:45 +09:00
Author: https://github.com/supercomputer7
Commit: 0fc60e41dd
Pull-request: https://github.com/SerenityOS/serenity/pull/1322
53 changed files with 397 additions and 573 deletions
|
@ -47,13 +47,13 @@ namespace ACPI {
|
|||
, StaticParser()
|
||||
|
||||
{
|
||||
kprintf("ACPI: Dynamic Parsing Enabled, Can parse AML\n");
|
||||
klog() << "ACPI: Dynamic Parsing Enabled, Can parse AML";
|
||||
}
|
||||
DynamicParser::DynamicParser(PhysicalAddress rsdp)
|
||||
: IRQHandler(9)
|
||||
, StaticParser(rsdp)
|
||||
{
|
||||
kprintf("ACPI: Dynamic Parsing Enabled, Can parse AML\n");
|
||||
klog() << "ACPI: Dynamic Parsing Enabled, Can parse AML";
|
||||
}
|
||||
|
||||
void DynamicParser::handle_irq(RegisterState&)
|
||||
|
|
|
@ -51,49 +51,49 @@ namespace ACPI {
|
|||
Parser::Parser(bool usable)
|
||||
{
|
||||
if (usable) {
|
||||
kprintf("ACPI: Setting up a functional parser\n");
|
||||
klog() << "ACPI: Setting up a functional parser";
|
||||
} else {
|
||||
kprintf("ACPI: Limited Initialization. Vital functions are disabled by a request\n");
|
||||
klog() << "ACPI: Limited Initialization. Vital functions are disabled by a request";
|
||||
}
|
||||
s_acpi_parser = this;
|
||||
}
|
||||
|
||||
PhysicalAddress Parser::find_table(const char*)
|
||||
{
|
||||
kprintf("ACPI: Requested to search for a table, Abort!\n");
|
||||
klog() << "ACPI: Requested to search for a table, Abort!";
|
||||
return {};
|
||||
}
|
||||
|
||||
void Parser::do_acpi_reboot()
|
||||
{
|
||||
kprintf("ACPI: Cannot invoke reboot!\n");
|
||||
klog() << "ACPI: Cannot invoke reboot!";
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
void Parser::do_acpi_shutdown()
|
||||
{
|
||||
kprintf("ACPI: Cannot invoke shutdown!\n");
|
||||
klog() << "ACPI: Cannot invoke shutdown!";
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
void Parser::enable_aml_interpretation()
|
||||
{
|
||||
kprintf("ACPI: No AML Interpretation Allowed\n");
|
||||
klog() << "ACPI: No AML Interpretation Allowed";
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
void Parser::enable_aml_interpretation(File&)
|
||||
{
|
||||
kprintf("ACPI: No AML Interpretation Allowed\n");
|
||||
klog() << "ACPI: No AML Interpretation Allowed";
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
void Parser::enable_aml_interpretation(u8*, u32)
|
||||
{
|
||||
kprintf("ACPI: No AML Interpretation Allowed\n");
|
||||
klog() << "ACPI: No AML Interpretation Allowed";
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
void Parser::disable_aml_interpretation()
|
||||
{
|
||||
kprintf("ACPI Limited: No AML Interpretation Allowed\n");
|
||||
klog() << "ACPI Limited: No AML Interpretation Allowed";
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
bool Parser::is_operable()
|
||||
|
|
|
@ -88,8 +88,8 @@ namespace ACPI {
|
|||
|
||||
void StaticParser::init_fadt()
|
||||
{
|
||||
kprintf("ACPI: Initializing Fixed ACPI data\n");
|
||||
kprintf("ACPI: Searching for the Fixed ACPI Data Table\n");
|
||||
klog() << "ACPI: Initializing Fixed ACPI data";
|
||||
klog() << "ACPI: Searching for the Fixed ACPI Data Table";
|
||||
|
||||
m_fadt = find_table("FACP");
|
||||
ASSERT(!m_fadt.is_null());
|
||||
|
@ -99,7 +99,7 @@ namespace ACPI {
|
|||
#ifdef ACPI_DEBUG
|
||||
dbg() << "ACPI: FADT @ V " << sdt << ", P " << (void*)fadt.as_ptr();
|
||||
#endif
|
||||
kprintf("ACPI: Fixed ACPI data, Revision %u, Length %u bytes\n", sdt->revision, sdt->length);
|
||||
klog() << "ACPI: Fixed ACPI data, Revision " << sdt->revision << ", Length " << sdt->length << " bytes";
|
||||
}
|
||||
|
||||
void StaticParser::do_acpi_reboot()
|
||||
|
@ -111,10 +111,10 @@ namespace ACPI {
|
|||
auto region = MM.allocate_kernel_region(m_fadt.page_base(), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read);
|
||||
auto* fadt = (const Structures::FADT*)region->vaddr().offset(m_fadt.offset_in_page().get()).as_ptr();
|
||||
if (fadt->h.revision >= 2) {
|
||||
kprintf("ACPI: Reboot, Sending value 0%x to Port 0x%x\n", fadt->reset_value, fadt->reset_reg.address);
|
||||
klog() << "ACPI: Reboot, Sending value 0x" << String::format("%x", fadt->reset_value) << " to Port 0x" << String::format("%x", fadt->reset_reg.address);
|
||||
IO::out8(fadt->reset_reg.address, fadt->reset_value);
|
||||
} else {
|
||||
kprintf("ACPI: Reboot, Not supported!\n");
|
||||
klog() << "ACPI: Reboot, Not supported!";
|
||||
}
|
||||
|
||||
ASSERT_NOT_REACHED(); /// If rebooting didn't work, halt.
|
||||
|
@ -122,7 +122,7 @@ namespace ACPI {
|
|||
|
||||
void StaticParser::do_acpi_shutdown()
|
||||
{
|
||||
kprintf("ACPI: Shutdown is not supported with the current configuration, Abort!\n");
|
||||
klog() << "ACPI: Shutdown is not supported with the current configuration, Abort!";
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
|
@ -159,12 +159,12 @@ namespace ACPI {
|
|||
|
||||
auto main_sdt_region = MM.allocate_kernel_region(m_main_system_description_table.page_base(), PAGE_ROUND_UP(length) + PAGE_SIZE, "ACPI Static Parser Initialization", Region::Access::Read, false, true);
|
||||
auto* sdt = (volatile Structures::SDTHeader*)main_sdt_region->vaddr().offset(m_main_system_description_table.offset_in_page().get()).as_ptr();
|
||||
kprintf("ACPI: Main Description Table valid? 0x%x\n", StaticParsing::validate_table(const_cast<Structures::SDTHeader&>(*sdt), length));
|
||||
klog() << "ACPI: Main Description Table valid? " << StaticParsing::validate_table(const_cast<Structures::SDTHeader&>(*sdt), length);
|
||||
|
||||
if (m_xsdt_supported) {
|
||||
volatile auto* xsdt = (volatile Structures::XSDT*)sdt;
|
||||
kprintf("ACPI: Using XSDT, Enumerating tables @ P 0x%x\n", m_main_system_description_table.get());
|
||||
kprintf("ACPI: XSDT Revision %d, Total length - %u\n", revision, length);
|
||||
klog() << "ACPI: Using XSDT, Enumerating tables @ P " << String::format("%p", m_main_system_description_table.get());
|
||||
klog() << "ACPI: XSDT Revision " << revision << ", Total length - " << length;
|
||||
#ifdef ACPI_DEBUG
|
||||
dbg() << "ACPI: XSDT pointer @ V " << xsdt;
|
||||
#endif
|
||||
|
@ -176,8 +176,8 @@ namespace ACPI {
|
|||
}
|
||||
} else {
|
||||
volatile auto* rsdt = (volatile Structures::RSDT*)sdt;
|
||||
kprintf("ACPI: Using RSDT, Enumerating tables @ P 0x%x\n", m_main_system_description_table.get());
|
||||
kprintf("ACPI: RSDT Revision %d, Total length - %u\n", revision, length);
|
||||
klog() << "ACPI: Using RSDT, Enumerating tables @ P " << String::format("%p", m_main_system_description_table.get());
|
||||
klog() << "ACPI: RSDT Revision " << revision << ", Total length - " << length;
|
||||
#ifdef ACPI_DEBUG
|
||||
dbg() << "ACPI: RSDT pointer @ V " << rsdt;
|
||||
#endif
|
||||
|
@ -215,12 +215,12 @@ namespace ACPI {
|
|||
, m_rsdp(StaticParsing::search_rsdp())
|
||||
{
|
||||
if (!m_rsdp.is_null()) {
|
||||
kprintf("ACPI: Using RSDP @ P 0x%x\n", m_rsdp);
|
||||
klog() << "ACPI: Using RSDP @ P " << String::format("%p", m_rsdp);
|
||||
m_operable = true;
|
||||
locate_static_data();
|
||||
} else {
|
||||
m_operable = false;
|
||||
kprintf("ACPI: Disabled, due to RSDP being absent\n");
|
||||
klog() << "ACPI: Disabled, due to RSDP being absent";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ namespace ACPI {
|
|||
: Parser(true)
|
||||
, m_rsdp(rsdp)
|
||||
{
|
||||
kprintf("ACPI: Using RSDP @ Px%x\n", rsdp.get());
|
||||
klog() << "ACPI: Using RSDP @ P " << String::format("%p", rsdp.get());
|
||||
m_operable = true;
|
||||
locate_static_data();
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ namespace ACPI {
|
|||
PhysicalAddress rsdp;
|
||||
auto region = MM.allocate_kernel_region(PhysicalAddress(0), PAGE_SIZE, "ACPI RSDP Searching", Region::Access::Read);
|
||||
u16 ebda_seg = (u16) * ((uint16_t*)((region->vaddr().get() & PAGE_MASK) + 0x40e));
|
||||
kprintf("ACPI: Probing EBDA, Segment 0x%x\n", ebda_seg);
|
||||
klog() << "ACPI: Probing EBDA, Segment 0x" << String::format("%x", ebda_seg);
|
||||
|
||||
rsdp = search_rsdp_in_ebda(ebda_seg);
|
||||
if (!rsdp.is_null())
|
||||
|
|
|
@ -62,7 +62,7 @@ void DMIDecoder::initialize_untrusted()
|
|||
|
||||
void DMIDecoder::set_64_bit_entry_initialization_values(PhysicalAddress entry)
|
||||
{
|
||||
kprintf("DMIDecoder: SMBIOS 64bit Entry point @ P 0x%x\n", m_entry64bit_point.get());
|
||||
klog() << "DMIDecoder: SMBIOS 64bit Entry point @ P " << String::format("%p", m_entry64bit_point.get());
|
||||
m_use_64bit_entry = true;
|
||||
|
||||
auto region = MM.allocate_kernel_region(entry.page_base(), PAGE_ROUND_UP(SMBIOS_SEARCH_AREA_SIZE), "DMI Decoder 64 bit Initialization", Region::Access::Read, false, false);
|
||||
|
@ -74,7 +74,7 @@ void DMIDecoder::set_64_bit_entry_initialization_values(PhysicalAddress entry)
|
|||
|
||||
void DMIDecoder::set_32_bit_entry_initialization_values(PhysicalAddress entry)
|
||||
{
|
||||
kprintf("DMIDecoder: SMBIOS 32bit Entry point @ P 0x%x\n", m_entry32bit_point.get());
|
||||
klog() << "DMIDecoder: SMBIOS 32bit Entry point @ P " << String::format("%p", m_entry32bit_point.get());
|
||||
m_use_64bit_entry = false;
|
||||
|
||||
auto region = MM.allocate_kernel_region(entry.page_base(), PAGE_ROUND_UP(SMBIOS_SEARCH_AREA_SIZE), "DMI Decoder 32 bit Initialization", Region::Access::Read, false, false);
|
||||
|
@ -90,18 +90,18 @@ void DMIDecoder::initialize_parser()
|
|||
|
||||
if (m_entry32bit_point.is_null() && m_entry64bit_point.is_null()) {
|
||||
m_operable = false;
|
||||
kprintf("DMI Decoder is disabled. Cannot find SMBIOS tables.\n");
|
||||
klog() << "DMI Decoder is disabled. Cannot find SMBIOS tables.";
|
||||
return;
|
||||
}
|
||||
|
||||
m_operable = true;
|
||||
kprintf("DMI Decoder is enabled\n");
|
||||
klog() << "DMI Decoder is enabled";
|
||||
if (!m_entry64bit_point.is_null()) {
|
||||
set_64_bit_entry_initialization_values(m_entry64bit_point);
|
||||
} else if (!m_entry32bit_point.is_null()) {
|
||||
set_32_bit_entry_initialization_values(m_entry32bit_point);
|
||||
}
|
||||
kprintf("DMIDecoder: Data table @ P 0x%x\n", m_structure_table.get());
|
||||
klog() << "DMIDecoder: Data table @ P " << String::format("%p", m_structure_table.get());
|
||||
enumerate_smbios_tables();
|
||||
}
|
||||
|
||||
|
@ -125,10 +125,10 @@ void DMIDecoder::enumerate_smbios_tables()
|
|||
#endif
|
||||
structures_count++;
|
||||
if (v_table_ptr->type == (u8)SMBIOS::TableType::EndOfTable) {
|
||||
kprintf("DMIDecoder: Detected table with type 127, End of SMBIOS data.\n");
|
||||
klog() << "DMIDecoder: Detected table with type 127, End of SMBIOS data.";
|
||||
break;
|
||||
}
|
||||
kprintf("DMIDecoder: Detected table with type %d\n", v_table_ptr->type);
|
||||
klog() << "DMIDecoder: Detected table with type " << v_table_ptr->type;
|
||||
m_smbios_tables.append(p_table);
|
||||
table_length -= v_table_ptr->length;
|
||||
|
||||
|
@ -205,7 +205,7 @@ DMIDecoder::DMIDecoder(bool trusted)
|
|||
, m_untrusted(!trusted)
|
||||
{
|
||||
if (!trusted) {
|
||||
kprintf("DMI Decoder initialized as untrusted due to user request.\n");
|
||||
klog() << "DMI Decoder initialized as untrusted due to user request.";
|
||||
}
|
||||
initialize_parser();
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ PhysicalAddress DMIDecoder::find_entry32bit_point()
|
|||
Vector<SMBIOS::PhysicalMemoryArray*>& DMIDecoder::get_physical_memory_areas()
|
||||
{
|
||||
// FIXME: Implement it...
|
||||
kprintf("DMIDecoder::get_physical_memory_areas() is not implemented.\n");
|
||||
klog() << "DMIDecoder::get_physical_memory_areas() is not implemented.";
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
bool DMIDecoder::is_reliable()
|
||||
|
@ -264,7 +264,7 @@ u64 DMIDecoder::get_bios_characteristics()
|
|||
auto* bios_info = (SMBIOS::BIOSInfo*)get_smbios_physical_table_by_type(0).as_ptr();
|
||||
ASSERT(bios_info != nullptr);
|
||||
|
||||
kprintf("DMIDecoder: BIOS info @ P 0x%x\n", bios_info);
|
||||
klog() << "DMIDecoder: BIOS info @ P " << String::format("%p", bios_info);
|
||||
return bios_info->bios_characteristics;
|
||||
}
|
||||
|
||||
|
@ -272,7 +272,7 @@ char* DMIDecoder::get_smbios_string(PhysicalAddress, u8)
|
|||
{
|
||||
// FIXME: Implement it...
|
||||
// FIXME: Make sure we have some mapping here so we don't rely on existing identity mapping...
|
||||
kprintf("DMIDecoder::get_smbios_string() is not implemented.\n");
|
||||
klog() << "DMIDecoder::get_smbios_string() is not implemented.";
|
||||
ASSERT_NOT_REACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -48,11 +48,11 @@ MultiProcessorParser::MultiProcessorParser()
|
|||
, m_operable((m_floating_pointer != (uintptr_t) nullptr))
|
||||
{
|
||||
if (m_floating_pointer != (uintptr_t) nullptr) {
|
||||
kprintf("MultiProcessor: Floating Pointer Structure @ P 0x%x\n", m_floating_pointer);
|
||||
klog() << "MultiProcessor: Floating Pointer Structure @ P " << String::format("%p", m_floating_pointer);
|
||||
parse_floating_pointer_data();
|
||||
parse_configuration_table();
|
||||
} else {
|
||||
kprintf("MultiProcessor: Can't Locate Floating Pointer Structure, disabled.\n");
|
||||
klog() << "MultiProcessor: Can't Locate Floating Pointer Structure, disabled.";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ uintptr_t MultiProcessorParser::search_floating_pointer()
|
|||
uintptr_t mp_floating_pointer = (uintptr_t) nullptr;
|
||||
auto region = MM.allocate_kernel_region(PhysicalAddress(0), PAGE_SIZE, "MultiProcessor Parser Floating Pointer Structure Finding", Region::Access::Read);
|
||||
u16 ebda_seg = (u16) * ((uint16_t*)((region->vaddr().get() & PAGE_MASK) + 0x40e));
|
||||
kprintf("MultiProcessor: Probing EBDA, Segment 0x%x\n", ebda_seg);
|
||||
klog() << "MultiProcessor: Probing EBDA, Segment 0x" << String::format("%x", ebda_seg);
|
||||
|
||||
mp_floating_pointer = search_floating_pointer_in_ebda(ebda_seg);
|
||||
if (mp_floating_pointer != (uintptr_t) nullptr)
|
||||
|
@ -195,12 +195,7 @@ Vector<RefPtr<PCIInterruptOverrideMetadata>> MultiProcessorParser::get_pci_inter
|
|||
for (auto id : pci_bus_ids) {
|
||||
if (id == v_entry_ptr->source_bus_id) {
|
||||
|
||||
kprintf("Interrupts: Bus %d, Polarity 0x%x, Trigger Mode 0x%x, INT %x, IOAPIC %d, IOAPIC INTIN %d\n", v_entry_ptr->source_bus_id,
|
||||
v_entry_ptr->polarity,
|
||||
v_entry_ptr->trigger_mode,
|
||||
v_entry_ptr->source_bus_irq,
|
||||
v_entry_ptr->destination_ioapic_id,
|
||||
v_entry_ptr->destination_ioapic_intin_pin);
|
||||
klog() << "Interrupts: Bus " << v_entry_ptr->source_bus_id << ", Polarity " << v_entry_ptr->polarity << ", Trigger Mode " << v_entry_ptr->trigger_mode << ", INT " << v_entry_ptr->source_bus_irq << ", IOAPIC " << v_entry_ptr->destination_ioapic_id << ", IOAPIC INTIN " << v_entry_ptr->destination_ioapic_intin_pin;
|
||||
overrides.append(adopt(*new PCIInterruptOverrideMetadata(
|
||||
v_entry_ptr->source_bus_id,
|
||||
v_entry_ptr->polarity,
|
||||
|
@ -213,14 +208,7 @@ Vector<RefPtr<PCIInterruptOverrideMetadata>> MultiProcessorParser::get_pci_inter
|
|||
}
|
||||
|
||||
for (auto override_metadata : overrides) {
|
||||
kprintf("Interrupts: Bus %d, Polarity 0x%x, PCI Device %d, Trigger Mode 0x%x, INT %x, IOAPIC %d, IOAPIC INTIN %d\n",
|
||||
override_metadata->bus(),
|
||||
override_metadata->polarity(),
|
||||
override_metadata->pci_device_number(),
|
||||
override_metadata->trigger_mode(),
|
||||
override_metadata->pci_interrupt_pin(),
|
||||
override_metadata->ioapic_id(),
|
||||
override_metadata->ioapic_interrupt_pin());
|
||||
klog() << "Interrupts: Bus " << override_metadata->bus() << ", Polarity " << override_metadata->polarity() << ", PCI Device " << override_metadata->pci_device_number() << ", Trigger Mode " << override_metadata->trigger_mode() << ", INT " << override_metadata->pci_interrupt_pin() << ", IOAPIC " << override_metadata->ioapic_id() << ", IOAPIC INTIN " << override_metadata->ioapic_interrupt_pin();
|
||||
}
|
||||
return overrides;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue