diff options
author | Andreas Kling <kling@serenityos.org> | 2020-01-20 13:06:14 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-01-20 13:13:03 +0100 |
commit | a246e9cd7ea88613387ed6fb87dd5651b3d2ccac (patch) | |
tree | edd41b63a392c1b51daab4543c7487426b924004 /Kernel/ACPI | |
parent | e07b34b9b839395da7e9f11de8faf85c74888291 (diff) | |
download | serenity-a246e9cd7ea88613387ed6fb87dd5651b3d2ccac.zip |
Use uintptr_t instead of u32 when storing pointers as integers
uintptr_t is 32-bit or 64-bit depending on the target platform.
This will help us write pointer size agnostic code so that when the day
comes that we want to do a 64-bit port, we'll be in better shape.
Diffstat (limited to 'Kernel/ACPI')
-rw-r--r-- | Kernel/ACPI/ACPIStaticParser.cpp | 30 | ||||
-rw-r--r-- | Kernel/ACPI/DMIDecoder.cpp | 20 | ||||
-rw-r--r-- | Kernel/ACPI/Definitions.h | 4 |
3 files changed, 27 insertions, 27 deletions
diff --git a/Kernel/ACPI/ACPIStaticParser.cpp b/Kernel/ACPI/ACPIStaticParser.cpp index 7a02af1f61..064fcaa8f9 100644 --- a/Kernel/ACPI/ACPIStaticParser.cpp +++ b/Kernel/ACPI/ACPIStaticParser.cpp @@ -63,8 +63,8 @@ ACPI_RAW::SDTHeader* ACPIStaticParser::find_table(const char* sig) dbgprintf("ACPI: Calling Find Table method!\n"); #endif for (auto* physical_sdt_ptr : m_main_sdt->get_sdt_pointers()) { - auto region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)physical_sdt_ptr)), (PAGE_SIZE * 2), "ACPI Static Parser Tables Finding", Region::Access::Read); - ACPI_RAW::SDTHeader* sdt = (ACPI_RAW::SDTHeader*)region->vaddr().offset(offset_in_page((u32)physical_sdt_ptr)).as_ptr(); + auto region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((uintptr_t)physical_sdt_ptr)), (PAGE_SIZE * 2), "ACPI Static Parser Tables Finding", Region::Access::Read); + ACPI_RAW::SDTHeader* sdt = (ACPI_RAW::SDTHeader*)region->vaddr().offset(offset_in_page((uintptr_t)physical_sdt_ptr)).as_ptr(); #ifdef ACPI_DEBUG dbgprintf("ACPI: Examining Table @ P 0x%x\n", physical_sdt_ptr); #endif @@ -85,20 +85,20 @@ void ACPIStaticParser::init_fadt() ASSERT(find_table("FACP") != nullptr); auto* fadt_ptr = find_table("FACP"); - auto checkup_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)(fadt_ptr))), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read); + auto checkup_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((uintptr_t)(fadt_ptr))), (PAGE_SIZE * 2), "ACPI Static Parser", Region::Access::Read); #ifdef ACPI_DEBUG dbgprintf("ACPI: Checking FADT Length to choose the correct mapping size\n"); #endif - ACPI_RAW::SDTHeader* sdt = (ACPI_RAW::SDTHeader*)checkup_region->vaddr().offset(offset_in_page((u32)(fadt_ptr))).as_ptr(); + ACPI_RAW::SDTHeader* sdt = (ACPI_RAW::SDTHeader*)checkup_region->vaddr().offset(offset_in_page((uintptr_t)(fadt_ptr))).as_ptr(); #ifdef ACPI_DEBUG dbgprintf("ACPI: FADT @ V 0x%x, P 0x%x\n", sdt, fadt_ptr); #endif u32 length = sdt->length; kprintf("ACPI: Fixed ACPI data, Revision %u\n", sdt->revision); - auto fadt_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)(fadt_ptr))), PAGE_ROUND_UP(length) + PAGE_SIZE, "ACPI Static Parser", Region::Access::Read); - m_fadt = make<ACPI::FixedACPIData>(*(ACPI_RAW::FADT*)fadt_region->vaddr().offset(offset_in_page((u32)(fadt_ptr))).as_ptr()); + auto fadt_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((uintptr_t)(fadt_ptr))), PAGE_ROUND_UP(length) + PAGE_SIZE, "ACPI Static Parser", Region::Access::Read); + m_fadt = make<ACPI::FixedACPIData>(*(ACPI_RAW::FADT*)fadt_region->vaddr().offset(offset_in_page((uintptr_t)(fadt_ptr))).as_ptr()); #ifdef ACPI_DEBUG dbgprintf("ACPI: Finished to initialize Fixed ACPI data\n"); #endif @@ -143,8 +143,8 @@ size_t ACPIStaticParser::get_table_size(ACPI_RAW::SDTHeader& p_header) #ifdef ACPI_DEBUG dbgprintf("ACPI: Checking SDT Length\n"); #endif - auto region = MM.allocate_kernel_region(PhysicalAddress((u32)&p_header & PAGE_MASK), (PAGE_SIZE * 2), "ACPI get_table_size()", Region::Access::Read); - volatile auto* sdt = (ACPI_RAW::SDTHeader*)region->vaddr().offset(offset_in_page((u32)&p_header)).as_ptr(); + auto region = MM.allocate_kernel_region(PhysicalAddress((uintptr_t)&p_header & PAGE_MASK), (PAGE_SIZE * 2), "ACPI get_table_size()", Region::Access::Read); + volatile auto* sdt = (ACPI_RAW::SDTHeader*)region->vaddr().offset(offset_in_page((uintptr_t)&p_header)).as_ptr(); return sdt->length; } @@ -154,8 +154,8 @@ u8 ACPIStaticParser::get_table_revision(ACPI_RAW::SDTHeader& p_header) #ifdef ACPI_DEBUG dbgprintf("ACPI: Checking SDT Revision\n"); #endif - auto region = MM.allocate_kernel_region(PhysicalAddress((u32)&p_header & PAGE_MASK), (PAGE_SIZE * 2), "ACPI get_table_revision()", Region::Access::Read); - volatile auto* sdt = (ACPI_RAW::SDTHeader*)region->vaddr().offset(offset_in_page((u32)&p_header)).as_ptr(); + auto region = MM.allocate_kernel_region(PhysicalAddress((uintptr_t)&p_header & PAGE_MASK), (PAGE_SIZE * 2), "ACPI get_table_revision()", Region::Access::Read); + volatile auto* sdt = (ACPI_RAW::SDTHeader*)region->vaddr().offset(offset_in_page((uintptr_t)&p_header)).as_ptr(); return sdt->revision; } @@ -175,8 +175,8 @@ void ACPIStaticParser::initialize_main_system_description_table() revision = get_table_revision(*m_main_system_description_table); } - auto main_sdt_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)m_main_system_description_table)), PAGE_ROUND_UP(length) + PAGE_SIZE, "ACPI Static Parser Initialization", Region::Access::Read, false, true); - volatile auto* sdt = (ACPI_RAW::SDTHeader*)main_sdt_region->vaddr().offset(offset_in_page((u32)m_main_system_description_table)).as_ptr(); + auto main_sdt_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((uintptr_t)m_main_system_description_table)), PAGE_ROUND_UP(length) + PAGE_SIZE, "ACPI Static Parser Initialization", Region::Access::Read, false, true); + volatile auto* sdt = (ACPI_RAW::SDTHeader*)main_sdt_region->vaddr().offset(offset_in_page((uintptr_t)m_main_system_description_table)).as_ptr(); kprintf("ACPI: Main Description Table valid? 0x%x\n", validate_acpi_table(const_cast<ACPI_RAW::SDTHeader&>(*sdt), length)); Vector<ACPI_RAW::SDTHeader*> sdt_pointers; @@ -236,8 +236,8 @@ void ACPIStaticParser::locate_all_aml_tables() kprintf("ACPI: Searching for AML Tables\n"); m_aml_tables_ptrs.append(m_fadt->get_dsdt()); for (auto* sdt_ptr : m_main_sdt->get_sdt_pointers()) { - auto region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)sdt_ptr)), (PAGE_SIZE * 2), "ACPI Static Parser AML Tables Finding", Region::Access::Read); - auto* sdt = (ACPI_RAW::SDTHeader*)region->vaddr().offset(offset_in_page((u32)sdt_ptr)).as_ptr(); + auto region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((uintptr_t)sdt_ptr)), (PAGE_SIZE * 2), "ACPI Static Parser AML Tables Finding", Region::Access::Read); + auto* sdt = (ACPI_RAW::SDTHeader*)region->vaddr().offset(offset_in_page((uintptr_t)sdt_ptr)).as_ptr(); #ifdef ACPI_DEBUG dbgprintf("ACPI: Examining Table @ P 0x%x\n", sdt_ptr); #endif @@ -387,7 +387,7 @@ ACPI::FixedACPIData::FixedACPIData(ACPI_RAW::FADT& fadt) ACPI_RAW::SDTHeader* ACPI::FixedACPIData::get_dsdt() { - if (m_x_dsdt_ptr != (u32) nullptr) + if (m_x_dsdt_ptr != (uintptr_t) nullptr) return (ACPI_RAW::SDTHeader*)m_x_dsdt_ptr; else { ASSERT((ACPI_RAW::SDTHeader*)m_dsdt_ptr != nullptr); diff --git a/Kernel/ACPI/DMIDecoder.cpp b/Kernel/ACPI/DMIDecoder.cpp index ead18076af..b01bbb2748 100644 --- a/Kernel/ACPI/DMIDecoder.cpp +++ b/Kernel/ACPI/DMIDecoder.cpp @@ -90,10 +90,10 @@ void DMIDecoder::enumerate_smbios_tables() u32 table_length = m_table_length; SMBIOS::TableHeader* p_table_ptr = m_structure_table; - PhysicalAddress paddr = PhysicalAddress(page_base_of((u32)p_table_ptr)); + PhysicalAddress paddr = PhysicalAddress(page_base_of((uintptr_t)p_table_ptr)); auto region = MM.allocate_kernel_region(paddr, PAGE_ROUND_UP(table_length), "DMI Decoder Enumerating SMBIOS", Region::Access::Read, false, false); - volatile SMBIOS::TableHeader* v_table_ptr = (SMBIOS::TableHeader*)region->vaddr().offset(offset_in_page((u32)p_table_ptr)).as_ptr(); + volatile SMBIOS::TableHeader* v_table_ptr = (SMBIOS::TableHeader*)region->vaddr().offset(offset_in_page((uintptr_t)p_table_ptr)).as_ptr(); #ifdef SMBIOS_DEBUG dbgprintf("DMIDecoder: Total Table length %d\n", m_table_length); #endif @@ -104,7 +104,7 @@ void DMIDecoder::enumerate_smbios_tables() dbgprintf("DMIDecoder: Examining table @ P 0x%x V 0x%x\n", p_table_ptr, v_table_ptr); #endif structures_count++; - if (v_table_ptr->type == (u32)SMBIOS::TableType::EndOfTable) { + if (v_table_ptr->type == (u8)SMBIOS::TableType::EndOfTable) { kprintf("DMIDecoder: Detected table with type 127, End of SMBIOS data.\n"); break; } @@ -113,8 +113,8 @@ void DMIDecoder::enumerate_smbios_tables() table_length -= v_table_ptr->length; size_t table_size = get_table_size(*p_table_ptr); - p_table_ptr = (SMBIOS::TableHeader*)((u32)p_table_ptr + (u32)table_size); - v_table_ptr = (SMBIOS::TableHeader*)((u32)v_table_ptr + (u32)table_size); + p_table_ptr = (SMBIOS::TableHeader*)((uintptr_t)p_table_ptr + table_size); + v_table_ptr = (SMBIOS::TableHeader*)((uintptr_t)v_table_ptr + table_size); #ifdef SMBIOS_DEBUG dbgprintf("DMIDecoder: Next table @ P 0x%x\n", p_table_ptr); #endif @@ -146,7 +146,7 @@ size_t DMIDecoder::get_table_size(SMBIOS::TableHeader& table) SMBIOS::TableHeader* DMIDecoder::get_next_physical_table(SMBIOS::TableHeader& p_table) { - return (SMBIOS::TableHeader*)((u32)&p_table + get_table_size(p_table)); + return (SMBIOS::TableHeader*)((uintptr_t)&p_table + get_table_size(p_table)); } SMBIOS::TableHeader* DMIDecoder::get_smbios_physical_table_by_handle(u16 handle) @@ -155,8 +155,8 @@ SMBIOS::TableHeader* DMIDecoder::get_smbios_physical_table_by_handle(u16 handle) for (auto* table : m_smbios_tables) { if (!table) continue; - auto region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)table)), PAGE_SIZE * 2, "DMI Decoder Finding Table", Region::Access::Read, false, false); - SMBIOS::TableHeader* table_v_ptr = (SMBIOS::TableHeader*)region->vaddr().offset(offset_in_page((u32)table)).as_ptr(); + auto region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((uintptr_t)table)), PAGE_SIZE * 2, "DMI Decoder Finding Table", Region::Access::Read, false, false); + SMBIOS::TableHeader* table_v_ptr = (SMBIOS::TableHeader*)region->vaddr().offset(offset_in_page((uintptr_t)table)).as_ptr(); if (table_v_ptr->handle == handle) { return table; @@ -170,8 +170,8 @@ SMBIOS::TableHeader* DMIDecoder::get_smbios_physical_table_by_type(u8 table_type for (auto* table : m_smbios_tables) { if (!table) continue; - auto region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((u32)table)), PAGE_ROUND_UP(PAGE_SIZE * 2), "DMI Decoder Finding Table", Region::Access::Read, false, false); - SMBIOS::TableHeader* table_v_ptr = (SMBIOS::TableHeader*)region->vaddr().offset(offset_in_page((u32)table)).as_ptr(); + auto region = MM.allocate_kernel_region(PhysicalAddress(page_base_of((uintptr_t)table)), PAGE_ROUND_UP(PAGE_SIZE * 2), "DMI Decoder Finding Table", Region::Access::Read, false, false); + SMBIOS::TableHeader* table_v_ptr = (SMBIOS::TableHeader*)region->vaddr().offset(offset_in_page((uintptr_t)table)).as_ptr(); if (table_v_ptr->type == table_type) { return table; } diff --git a/Kernel/ACPI/Definitions.h b/Kernel/ACPI/Definitions.h index 1f1bd3928d..9fadb6e3d4 100644 --- a/Kernel/ACPI/Definitions.h +++ b/Kernel/ACPI/Definitions.h @@ -201,7 +201,7 @@ struct GenericAddressStructure { this->bit_width = other.bit_width; this->bit_offset = other.bit_offset; this->access_size = other.access_size; - this->address = (u32)other.address; + this->address = (uintptr_t)other.address; return *this; } GenericAddressStructure& operator=(const ACPI_RAW::GenericAddressStructure& other) @@ -210,7 +210,7 @@ struct GenericAddressStructure { this->bit_width = other.bit_width; this->bit_offset = other.bit_offset; this->access_size = other.access_size; - this->address = (u32)other.address; + this->address = (uintptr_t)other.address; return *this; } }; |