diff options
Diffstat (limited to 'dev/kernel/HALKit/AMD64')
| -rw-r--r-- | dev/kernel/HALKit/AMD64/HalKernelMain.cc | 1 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc | 9 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Processor.h | 1 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc | 33 |
4 files changed, 25 insertions, 19 deletions
diff --git a/dev/kernel/HALKit/AMD64/HalKernelMain.cc b/dev/kernel/HALKit/AMD64/HalKernelMain.cc index 7f3d4137..ce8c1245 100644 --- a/dev/kernel/HALKit/AMD64/HalKernelMain.cc +++ b/dev/kernel/HALKit/AMD64/HalKernelMain.cc @@ -14,7 +14,6 @@ #include <CFKit/Property.h> #include <modules/CoreGfx/TextGfx.h> #include <KernelKit/Timer.h> -#include <modules/CoreGfx/CoreWindow.h> #include <FirmwareKit/EFI/API.h> #include <FirmwareKit/EFI/EFI.h> diff --git a/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc b/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc index 16fe843a..c6c24be1 100644 --- a/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc +++ b/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc @@ -143,13 +143,14 @@ namespace Kernel::HAL pte->Wr = !!(flags & kMMFlagsWr); pte->User = !!(flags & kMMFlagsUser); pte->Nx = !!(flags & kMMFlagsNX); - pte->Pcd = !(flags & kMMFlagsPCD); - pte->PhysicalAddress = (UIntPtr)(physical_address); - - mmi_page_status(pte); + pte->Pcd = !!(flags & kMMFlagsPCD); + pte->Pwt = !!(flags & kMMFlagsPwt); + pte->PhysicalAddress = ((UIntPtr)(physical_address)); hal_invl_tlb(virtual_address); + mmi_page_status(pte); + return kErrorSuccess; } } // namespace Kernel::HAL diff --git a/dev/kernel/HALKit/AMD64/Processor.h b/dev/kernel/HALKit/AMD64/Processor.h index f2e9c2ea..13819f3e 100644 --- a/dev/kernel/HALKit/AMD64/Processor.h +++ b/dev/kernel/HALKit/AMD64/Processor.h @@ -74,6 +74,7 @@ namespace Kernel::HAL kMMFlagsUser = 1 << 3, kMMFlagsNX = 1 << 4, kMMFlagsPCD = 1 << 5, + kMMFlagsPwt = 1 << 6, kMMFlagsCount = 4, }; diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index 08fd02ab..3955dd78 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -74,10 +74,10 @@ STATIC Void drv_compute_disk_ahci() noexcept const UInt16 kSzIdent = 512; /// Push it to the stack - UInt16* identify_data = new UInt16[kSzIdent]; + UInt8* identify_data = new UInt8[kSzIdent]; /// Send AHCI command for identification. - drv_std_input_output_ahci<NO, YES, YES>(0, (UInt8*)identify_data, kAHCISectorSize, kSzIdent); + drv_std_input_output_ahci<NO, YES, YES>(0, identify_data, kAHCISectorSize, kSzIdent); /// Extract 48-bit LBA. UInt64 lba48_sectors = 0; @@ -91,7 +91,16 @@ STATIC Void drv_compute_disk_ahci() noexcept else kSATASectorCount = lba48_sectors; - (Void)(kout << "Device: " << kCurrentDiskModel << kendl); + for (Int32 i = 0; i < 20; i++) + { + kCurrentDiskModel[i * 2] = (identify_data[27 + i] >> 8) & 0xFF; + kCurrentDiskModel[i * 2 + 1] = identify_data[27 + i] & 0xFF; + } + + kCurrentDiskModel[40] = '\0'; + + (Void)(kout << "SATA Sector Count: " << hex_number(kSATASectorCount) << kendl); + (Void)(kout << "SATA Disk Model: " << kCurrentDiskModel << kendl); delete[] identify_data; identify_data = nullptr; @@ -102,17 +111,15 @@ STATIC Void drv_compute_disk_ahci() noexcept /// @return The slot, or ~0. STATIC Int32 drv_find_cmd_slot_ahci(HbaPort* port) noexcept { - UInt32 slots = (port->Sact | port->Ci); + UInt32 slots = port->Sact | port->Ci; - for (Int32 i = 0; i < kSATAPortCnt; ++i) + for (Int32 i = 0; i < kSATAPortCnt; ++i) // AHCI supports up to 32 slots { - if ((slots & 1) == 0) + if ((slots & (1U << i)) == 0) return i; - - slots >>= 1; } - return ~0; + return -1; // no free slot found } /// @brief Send an AHCI command, according to the template parameters. @@ -159,8 +166,6 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz auto ctba_phys = ((UInt64)command_header->Ctbau << 32) | command_header->Ctba; auto command_table = reinterpret_cast<volatile HbaCmdTbl*>(ctba_phys); - rt_set_memory((HbaCmdTbl*)command_table, 0, sizeof(HbaCmdTbl) + (command_header->Prdtl - 1) * sizeof(HbaPrdtEntry)); - MUST_PASS(command_table); UIntPtr buffer_phys = HAL::hal_get_phys_address(buffer); @@ -278,12 +283,12 @@ STATIC Bool drv_std_init_ahci(UInt16& pi, BOOL& atapi) if (kSATADev.Subclass() == kSATASubClass && kSATADev.ProgIf() == kSATAProgIfAHCI) { - HbaMem* mem_ahci = (HbaMem*)kSATADev.Bar(kSATABar5); - kSATADev.EnableMmio(); kSATADev.BecomeBusMaster(); - HAL::mm_map_page((VoidPtr)mem_ahci, (VoidPtr)mem_ahci, HAL::kMMFlagsPresent | HAL::kMMFlagsWr | HAL::kMMFlagsPCD); + HbaMem* mem_ahci = (HbaMem*)kSATADev.Bar(kSATABar5); + + HAL::mm_map_page((VoidPtr)mem_ahci, (VoidPtr)mem_ahci, HAL::kMMFlagsPresent | HAL::kMMFlagsWr | HAL::kMMFlagsPCD | HAL::kMMFlagsPwt); UInt32 ports_implemented = mem_ahci->Pi; UInt16 ahci_index = 0; |
