mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:07:43 +00:00
AK: Add global FlatPtr typedef. It's u32 or u64, based on sizeof(void*)
Use this instead of uintptr_t throughout the codebase. This makes it possible to pass a FlatPtr to something that has u32 and u64 overloads.
This commit is contained in:
parent
b98d8ad5b0
commit
b1058b33fb
36 changed files with 164 additions and 161 deletions
|
@ -247,7 +247,7 @@ namespace ACPI {
|
|||
dbg() << "ACPI: Looking for RSDP in EBDA @ V " << (void*)rsdp_str << ", P " << (void*)p_rsdp_str;
|
||||
#endif
|
||||
if (!strncmp("RSD PTR ", rsdp_str, strlen("RSD PTR ")))
|
||||
return PhysicalAddress((uintptr_t)p_rsdp_str);
|
||||
return PhysicalAddress((FlatPtr)p_rsdp_str);
|
||||
p_rsdp_str += 16;
|
||||
}
|
||||
return {};
|
||||
|
@ -262,7 +262,7 @@ namespace ACPI {
|
|||
dbg() << "ACPI: Looking for RSDP in BIOS ROM area @ V " << (void*)rsdp_str << ", P " << (void*)p_rsdp_str;
|
||||
#endif
|
||||
if (!strncmp("RSD PTR ", rsdp_str, strlen("RSD PTR ")))
|
||||
return PhysicalAddress((uintptr_t)p_rsdp_str);
|
||||
return PhysicalAddress((FlatPtr)p_rsdp_str);
|
||||
p_rsdp_str += 16;
|
||||
}
|
||||
return {};
|
||||
|
@ -320,8 +320,8 @@ namespace ACPI {
|
|||
auto main_sdt_region = MM.allocate_kernel_region(xsdt.page_base(), PAGE_SIZE, "ACPI Static Parsing search_table_in_xsdt()", Region::Access::Read, false, true);
|
||||
auto* xsdt_ptr = (volatile Structures::XSDT*)main_sdt_region->vaddr().offset(xsdt.offset_in_page().get()).as_ptr();
|
||||
for (u32 i = 0; i < ((xsdt_ptr->h.length - sizeof(Structures::SDTHeader)) / sizeof(u64)); i++) {
|
||||
if (match_table_signature(PhysicalAddress((uintptr_t)xsdt_ptr->table_ptrs[i]), signature))
|
||||
return PhysicalAddress((uintptr_t)xsdt_ptr->table_ptrs[i]);
|
||||
if (match_table_signature(PhysicalAddress((FlatPtr)xsdt_ptr->table_ptrs[i]), signature))
|
||||
return PhysicalAddress((FlatPtr)xsdt_ptr->table_ptrs[i]);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -347,8 +347,8 @@ namespace ACPI {
|
|||
auto* rsdt_ptr = (volatile Structures::RSDT*)main_sdt_region->vaddr().offset(rsdt.offset_in_page().get()).as_ptr();
|
||||
|
||||
for (u32 i = 0; i < ((rsdt_ptr->h.length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) {
|
||||
if (match_table_signature(PhysicalAddress((uintptr_t)rsdt_ptr->table_ptrs[i]), signature))
|
||||
return PhysicalAddress((uintptr_t)rsdt_ptr->table_ptrs[i]);
|
||||
if (match_table_signature(PhysicalAddress((FlatPtr)rsdt_ptr->table_ptrs[i]), signature))
|
||||
return PhysicalAddress((FlatPtr)rsdt_ptr->table_ptrs[i]);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ void DMIDecoder::enumerate_smbios_tables()
|
|||
|
||||
size_t table_size = get_table_size(p_table);
|
||||
p_table = p_table.offset(table_size);
|
||||
v_table_ptr = (SMBIOS::TableHeader*)((uintptr_t)v_table_ptr + table_size);
|
||||
v_table_ptr = (SMBIOS::TableHeader*)((FlatPtr)v_table_ptr + table_size);
|
||||
#ifdef SMBIOS_DEBUG
|
||||
dbg() << "DMIDecoder: Next table @ P 0x" << p_table.get();
|
||||
#endif
|
||||
|
@ -221,7 +221,7 @@ PhysicalAddress DMIDecoder::find_entry64bit_point()
|
|||
dbg() << "DMI Decoder: Looking for 64 bit Entry point @ V " << (void*)entry_str << " P " << (void*)tested_physical_ptr;
|
||||
#endif
|
||||
if (!strncmp("_SM3_", entry_str, strlen("_SM3_")))
|
||||
return PhysicalAddress((uintptr_t)tested_physical_ptr);
|
||||
return PhysicalAddress((FlatPtr)tested_physical_ptr);
|
||||
|
||||
tested_physical_ptr += 16;
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ PhysicalAddress DMIDecoder::find_entry32bit_point()
|
|||
dbg() << "DMI Decoder: Looking for 32 bit Entry point @ V " << (void*)entry_str << " P " << (void*)tested_physical_ptr;
|
||||
#endif
|
||||
if (!strncmp("_SM_", entry_str, strlen("_SM_")))
|
||||
return PhysicalAddress((uintptr_t)tested_physical_ptr);
|
||||
return PhysicalAddress((FlatPtr)tested_physical_ptr);
|
||||
|
||||
tested_physical_ptr += 16;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
klog() << "DMIDecoder: BIOS info @ " << PhysicalAddress((uintptr_t)bios_info);
|
||||
klog() << "DMIDecoder: BIOS info @ " << PhysicalAddress((FlatPtr)bios_info);
|
||||
return bios_info->bios_characteristics;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ void MultiProcessorParser::initialize()
|
|||
|
||||
MultiProcessorParser::MultiProcessorParser()
|
||||
: m_floating_pointer(search_floating_pointer())
|
||||
, m_operable((m_floating_pointer != (uintptr_t) nullptr))
|
||||
, m_operable((m_floating_pointer != (FlatPtr) nullptr))
|
||||
{
|
||||
if (m_floating_pointer != (uintptr_t) nullptr) {
|
||||
if (m_floating_pointer != (FlatPtr) nullptr) {
|
||||
klog() << "MultiProcessor: Floating Pointer Structure @ " << PhysicalAddress(m_floating_pointer);
|
||||
parse_floating_pointer_data();
|
||||
parse_configuration_table();
|
||||
|
@ -89,7 +89,7 @@ void MultiProcessorParser::parse_configuration_table()
|
|||
p_entry = (MultiProcessor::EntryHeader*)(u32)p_entry + (u8)MultiProcessor::ConfigurationTableEntryLength::Processor;
|
||||
break;
|
||||
case ((u8)MultiProcessor::ConfigurationTableEntryType::Bus):
|
||||
m_bus_entries.append((uintptr_t)p_entry);
|
||||
m_bus_entries.append((FlatPtr)p_entry);
|
||||
entry = (MultiProcessor::EntryHeader*)(u32)entry + (u8)MultiProcessor::ConfigurationTableEntryLength::Bus;
|
||||
p_entry = (MultiProcessor::EntryHeader*)(u32)p_entry + (u8)MultiProcessor::ConfigurationTableEntryLength::Bus;
|
||||
break;
|
||||
|
@ -98,7 +98,7 @@ void MultiProcessorParser::parse_configuration_table()
|
|||
p_entry = (MultiProcessor::EntryHeader*)(u32)p_entry + (u8)MultiProcessor::ConfigurationTableEntryLength::IOAPIC;
|
||||
break;
|
||||
case ((u8)MultiProcessor::ConfigurationTableEntryType::IO_Interrupt_Assignment):
|
||||
m_io_interrupt_redirection_entries.append((uintptr_t)p_entry);
|
||||
m_io_interrupt_redirection_entries.append((FlatPtr)p_entry);
|
||||
entry = (MultiProcessor::EntryHeader*)(u32)entry + (u8)MultiProcessor::ConfigurationTableEntryLength::IO_Interrupt_Assignment;
|
||||
p_entry = (MultiProcessor::EntryHeader*)(u32)p_entry + (u8)MultiProcessor::ConfigurationTableEntryLength::IO_Interrupt_Assignment;
|
||||
break;
|
||||
|
@ -124,20 +124,20 @@ void MultiProcessorParser::parse_configuration_table()
|
|||
}
|
||||
}
|
||||
|
||||
uintptr_t MultiProcessorParser::search_floating_pointer()
|
||||
FlatPtr MultiProcessorParser::search_floating_pointer()
|
||||
{
|
||||
uintptr_t mp_floating_pointer = (uintptr_t) nullptr;
|
||||
FlatPtr mp_floating_pointer = (FlatPtr) 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));
|
||||
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)
|
||||
if (mp_floating_pointer != (FlatPtr) nullptr)
|
||||
return mp_floating_pointer;
|
||||
return search_floating_pointer_in_bios_area();
|
||||
}
|
||||
|
||||
uintptr_t MultiProcessorParser::search_floating_pointer_in_ebda(u16 ebda_segment)
|
||||
FlatPtr MultiProcessorParser::search_floating_pointer_in_ebda(u16 ebda_segment)
|
||||
{
|
||||
auto floating_pointer_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)(ebda_segment << 4))), PAGE_ROUND_UP(1024), "MultiProcessor Parser floating_pointer Finding #1", Region::Access::Read, false, true);
|
||||
char* p_floating_pointer_str = (char*)(PhysicalAddress(ebda_segment << 4).as_ptr());
|
||||
|
@ -146,12 +146,12 @@ uintptr_t MultiProcessorParser::search_floating_pointer_in_ebda(u16 ebda_segment
|
|||
dbg() << "MultiProcessor: Looking for floating pointer structure in EBDA @ V0x " << String::format("%x", floating_pointer_str) << ", P0x" << String::format("%x", p_floating_pointer_str);
|
||||
#endif
|
||||
if (!strncmp("_MP_", floating_pointer_str, strlen("_MP_")))
|
||||
return (uintptr_t)p_floating_pointer_str;
|
||||
return (FlatPtr)p_floating_pointer_str;
|
||||
p_floating_pointer_str += 16;
|
||||
}
|
||||
return (uintptr_t) nullptr;
|
||||
return (FlatPtr) nullptr;
|
||||
}
|
||||
uintptr_t MultiProcessorParser::search_floating_pointer_in_bios_area()
|
||||
FlatPtr MultiProcessorParser::search_floating_pointer_in_bios_area()
|
||||
{
|
||||
auto floating_pointer_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)0xE0000)), PAGE_ROUND_UP(0xFFFFF - 0xE0000), "MultiProcessor Parser floating_pointer Finding #2", Region::Access::Read, false, true);
|
||||
char* p_floating_pointer_str = (char*)(PhysicalAddress(0xE0000).as_ptr());
|
||||
|
@ -160,10 +160,10 @@ uintptr_t MultiProcessorParser::search_floating_pointer_in_bios_area()
|
|||
dbg() << "MultiProcessor: Looking for floating pointer structure in BIOS area @ V0x " << String::format("%x", floating_pointer_str) << ", P0x" << String::format("%x", p_floating_pointer_str);
|
||||
#endif
|
||||
if (!strncmp("_MP_", floating_pointer_str, strlen("_MP_")))
|
||||
return (uintptr_t)p_floating_pointer_str;
|
||||
return (FlatPtr)p_floating_pointer_str;
|
||||
p_floating_pointer_str += 16;
|
||||
}
|
||||
return (uintptr_t) nullptr;
|
||||
return (FlatPtr) nullptr;
|
||||
}
|
||||
|
||||
Vector<unsigned> MultiProcessorParser::get_pci_bus_ids()
|
||||
|
|
|
@ -225,14 +225,14 @@ protected:
|
|||
|
||||
Vector<unsigned> get_pci_bus_ids();
|
||||
|
||||
uintptr_t search_floating_pointer();
|
||||
uintptr_t search_floating_pointer_in_ebda(u16 ebda_segment);
|
||||
uintptr_t search_floating_pointer_in_bios_area();
|
||||
FlatPtr search_floating_pointer();
|
||||
FlatPtr search_floating_pointer_in_ebda(u16 ebda_segment);
|
||||
FlatPtr search_floating_pointer_in_bios_area();
|
||||
|
||||
uintptr_t m_floating_pointer;
|
||||
uintptr_t m_configuration_table;
|
||||
Vector<uintptr_t> m_io_interrupt_redirection_entries;
|
||||
Vector<uintptr_t> m_bus_entries;
|
||||
FlatPtr m_floating_pointer;
|
||||
FlatPtr m_configuration_table;
|
||||
Vector<FlatPtr> m_io_interrupt_redirection_entries;
|
||||
Vector<FlatPtr> m_bus_entries;
|
||||
bool m_operable;
|
||||
|
||||
size_t m_configuration_table_length;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue