summaryrefslogtreecommitdiffhomepage
path: root/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Builtins/ACPI/ACPI.hxx2
-rw-r--r--Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx18
-rw-r--r--Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp42
-rw-r--r--Kernel/HALKit/AMD64/Processor.hpp30
4 files changed, 37 insertions, 55 deletions
diff --git a/Kernel/Builtins/ACPI/ACPI.hxx b/Kernel/Builtins/ACPI/ACPI.hxx
index d9bfeaca..430a39f4 100644
--- a/Kernel/Builtins/ACPI/ACPI.hxx
+++ b/Kernel/Builtins/ACPI/ACPI.hxx
@@ -81,7 +81,7 @@ namespace NewOS
UInt32 OemRev;
UInt32 CreatorID;
UInt32 CreatorRevision;
- UInt64 AddressArr[];
+ UInt32 AddressArr[];
};
} // namespace NewOS
diff --git a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
index f92554f8..adeeb10d 100644
--- a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
+++ b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
@@ -76,36 +76,38 @@ namespace NewOS
}
/// FIXME
- RSDT* xsdt = (RSDT*)rsdPtr->XsdtAddress;
+ RSDT* xsdt = (RSDT*)(rsdPtr->RsdtAddress);
- if (NewOS::HAL::ke_map_address((PDE*)hal_read_cr3(), rsdPtr->XsdtAddress, (UIntPtr)xsdt, NewOS::HAL::eFlagsRw))
- return ErrorOr<voidPtr>{-5};
-
- Int64 num = (xsdt->Length - sizeof(SDT)) / sizeof(UInt64);
+ Int64 num = (xsdt->Length - sizeof(SDT)) / sizeof(UInt32);
if (num < 1)
{
+ kcout << "ACPI: No entries." << endl;
return ErrorOr<voidPtr>{-6};
}
this->fEntries = num;
kcout << "ACPI: Number of entries: " << number(this->fEntries) << endl;
+ kcout << "ACPI: Revision: " << number(xsdt->Revision) << endl;
+ kcout << "ACPI: XSDT: " << xsdt->Signature << endl;
kcout << "ACPI: Address of XSDT: " << hex_number((UIntPtr)xsdt) << endl;
const short cAcpiSignatureLength = 4;
for (Size index = 0; index < this->fEntries; ++index)
{
- SDT* sdt = (SDT*)(xsdt->AddressArr[index]);
+ SDT& sdt = *(SDT*)xsdt->AddressArr[index];
+
+ kcout << "ACPI: Revision: " << number(sdt.CreatorID) << endl;
for (short signature_index = 0; signature_index < cAcpiSignatureLength; ++signature_index)
{
- if (sdt->Signature[signature_index] != signature[signature_index])
+ if (sdt.Signature[signature_index] != signature[signature_index])
break;
if (signature_index == (cAcpiSignatureLength - 1))
- return ErrorOr<voidPtr>(reinterpret_cast<voidPtr>(sdt));
+ return ErrorOr<voidPtr>(reinterpret_cast<voidPtr>(&sdt));
}
}
diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
index 287b1882..5ab40532 100644
--- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
+++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
@@ -137,37 +137,17 @@ namespace NewOS::HAL
if (kApicMadt != nullptr)
{
- auto madt = (SDT*)kApicMadt;
-
- const UInt8* madt_end = (const UInt8*)madt + madt->Length;
- const UInt8* entry_ptr = (const UInt8*)(madt + 1);
-
- while (entry_ptr < madt_end)
- {
- const MadtType::MadtAddress* entry_header = (const MadtType::MadtAddress*)entry_ptr;
-
- switch (entry_header->Flags)
- {
- case 0: {
- const MadtProcessorLocalApic* local_apic = (const MadtProcessorLocalApic*)entry_ptr;
- if (local_apic->Flags & 1)
- {
- // Processor is enabled
- kcout << "Processor ID: %d, APIC ID: %d\n"
- << number(local_apic->AcpiProcessorId) << number(local_apic->ApicId);
- }
- break;
- }
- default:
- break;
- }
-
- entry_ptr += entry_header->RecordLen;
- }
-
- while (true)
- {
- }
+ MadtType* madt = (MadtType*)kApicMadt;
+
+ constexpr auto cMaxProbableCores = 4;
+
+ for (SizeT i = 0; i < cMaxProbableCores; ++i)
+ {
+ if (madt->MadtRecords[i].Flags == 0x01) // if local apic.
+ {
+ // then register as a core for scheduler.
+ }
+ }
}
else
{
diff --git a/Kernel/HALKit/AMD64/Processor.hpp b/Kernel/HALKit/AMD64/Processor.hpp
index 608a502f..4916d845 100644
--- a/Kernel/HALKit/AMD64/Processor.hpp
+++ b/Kernel/HALKit/AMD64/Processor.hpp
@@ -74,24 +74,27 @@ namespace NewOS::HAL
if (!pde->Pte[pml4_index].Present)
{
pde->Pte[pml4_index].Present = true;
- kcout << "PM: It is present now.\r";
+ kcout << "PM is present now.\r";
+
+ pde->Pte[pml4_index].PhysicalAddress = phys_addr;
+ pde->Pte[pml4_index].Rw = flags & eFlagsRw;
+ pde->Pte[pml4_index].User = flags & eFlagsUser;
+ pde->Pte[pml4_index].ExecDisable = flags & eFlagsExecDisable;
+
+ return 0;
}
else
{
- kcout << "PM: It is already present.\r";
- kcout << "Address? " << hex_number(pde->Pte[pml4_index].PhysicalAddress) << endl;
- kcout << "User? " << (pde->Pte[pml4_index].User ? "yes" : "no") << "\r";
- kcout << "RW? " << (pde->Pte[pml4_index].Rw ? "yes" : "no") << "\r";
+ kcout << "PM is already present.\r";
- return 1;
- }
+ kcout << "PhysicalAddress: " << hex_number(pde->Pte[pml4_index].PhysicalAddress) << endl;
+ kcout << "User: " << (pde->Pte[pml4_index].User ? "yes" : "no") << "\r";
+ kcout << "RW: " << (pde->Pte[pml4_index].Rw ? "yes" : "no") << "\r";
- pde->Pte[pml4_index].PhysicalAddress = phys_addr;
- pde->Pte[pml4_index].Rw = flags & eFlagsRw;
- pde->Pte[pml4_index].User = flags & eFlagsUser;
- pde->Pte[pml4_index].ExecDisable = flags & eFlagsExecDisable;
+ return 1;
+ }
- return 0;
+ return 0;
}
/// @brief Map address to PDE.
@@ -102,9 +105,6 @@ namespace NewOS::HAL
inline void ke_unmap_address(PDE* pde, UIntPtr phys_addr, UIntPtr virt_addr, UInt32 flags)
{
UInt16 pml4_index = (virt_addr >> 39) & 0x1FF;
- UInt16 pdpt_index = (virt_addr >> 30) & 0x1FF;
- UInt16 pd_index = (virt_addr >> 21) & 0x1FF;
- UInt16 pt_index = (virt_addr >> 12) & 0x1FF;
if (pde->Pte[pml4_index].Present)
{