diff options
Diffstat (limited to 'dev/kernel')
| -rw-r--r-- | dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc | 2 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc | 12 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc | 10 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc | 24 |
4 files changed, 26 insertions, 22 deletions
diff --git a/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc b/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc index 63796393..6a9a89b7 100644 --- a/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc +++ b/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc @@ -91,7 +91,7 @@ namespace Kernel::HAL // Lastly, grab the pte entry. NE_PDE* pde_struct = reinterpret_cast<NE_PDE*>(pt_base); - return pde_struct->fEntries[pt_index]->PhysicalAddress; + return pde_struct->fEntries[pt_entry]->PhysicalAddress; } /***********************************************************************************/ diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index 21d95b5d..f74db6c0 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -15,6 +15,7 @@ * */ +#include "NewKit/Defines.h" #include <KernelKit/DeviceMgr.h> #include <KernelKit/DriveMgr.h> #include <KernelKit/ProcessScheduler.h> @@ -71,13 +72,13 @@ STATIC Void drv_compute_disk_ahci() noexcept kSATASectorCount = 0UL; /// Normally 512 bytes, but add an additional 512 bytes to make 1 KIB. - const UInt16 kSzIdent = kib_cast(1); + const UInt16 kSzIdent = 256; /// Push it to the stack - UInt8* identify_data ATTRIBUTE(aligned(4096)) = new UInt8[kSzIdent]; + UInt16* identify_data ATTRIBUTE(aligned(4096)) = new UInt16[kSzIdent]; /// Send AHCI command for identification. - drv_std_input_output_ahci<NO, YES, YES>(0, identify_data, kAHCISectorSize, kSzIdent); + drv_std_input_output_ahci<NO, YES, YES>(0, (UInt8*)identify_data, kAHCISectorSize, kSzIdent); /// Extract 48-bit LBA. @@ -90,6 +91,9 @@ STATIC Void drv_compute_disk_ahci() noexcept kSATASectorCount = (identify_data[61] << 16) | identify_data[60]; else kSATASectorCount = lba48_sectors; + + delete[] identify_data; + identify_data = nullptr; } /// @brief Finds a command slot for a HBA port. @@ -140,8 +144,10 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz /// Offset to specific command slot. command_header += slot; + /// check for command header. MUST_PASS(command_header); + /// 4kb per PRD. constexpr const UInt32 kMaxPRDSize = kib_cast(4); command_header->Cfl = sizeof(FisRegH2D) / sizeof(UInt32); diff --git a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc index 5aabf144..f04d25eb 100644 --- a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc @@ -28,11 +28,11 @@ using namespace Kernel::HAL; /// BUGS: 0 -STATIC Boolean kATADetected = false; -STATIC Int32 kATADeviceType = kATADeviceCount; -STATIC Char kATAData[kATADataLen] = {0}; +STATIC Boolean kATADetected = false; +STATIC Int32 kATADeviceType = kATADeviceCount; +STATIC UInt16 kATAIdentifyData[kATADataLen] = {0}; STATIC Kernel::PCI::Device kATADevice; -STATIC Char kCurrentDiskModel[50] = {"GENERIC DMA"}; +STATIC Char kATADiskModel[50] = {"GENERIC DMA"}; Boolean drv_std_wait_io(UInt16 IO) { @@ -198,7 +198,7 @@ Boolean drv_std_detected(Void) /***********************************************************************************/ Kernel::SizeT drv_get_sector_count() { - return (kATAData[61] << 16) | kATAData[60]; + return (kATAIdentifyData[61] << 16) | kATAIdentifyData[60]; } /***********************************************************************************/ diff --git a/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc index aa3b50c4..fc608e94 100644 --- a/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc @@ -25,12 +25,12 @@ using namespace Kernel::HAL; /// BUGS: 0 -#define kATADataLen 512 +#define kATADataLen 256 -STATIC Boolean kATADetected = false; -STATIC Int32 kATADeviceType = kATADeviceCount; -STATIC Char kATAData[kATADataLen] = {0}; -STATIC Char kCurrentDiskModel[50] = {"GENERIC PIO"}; +STATIC Boolean kATADetected = false; +STATIC Int32 kATADeviceType = kATADeviceCount; +STATIC UInt16 kATAIdentifyData[kATADataLen] = {0}; +STATIC Char kATADiskModel[50] = {"GENERIC PIO"}; static Boolean drv_pio_std_wait_io(UInt16 IO) { @@ -96,20 +96,18 @@ ATAInit_Retry: for (SizeT i = 0ul; i < kATADataLen; ++i) { - kATAData[i] = HAL::rt_in16(OutBus + ATA_REG_DATA); + kATAIdentifyData[i] = HAL::rt_in16(OutBus + ATA_REG_DATA); } for (Int32 i = 0; i < 20; i++) { - kCurrentDiskModel[i * 2] = kATAData[27 + i] >> 8; - kCurrentDiskModel[i * 2 + 1] = kATAData[27 + i + 1] & 0xFF; + kATADiskModel[i * 2] = (kATAIdentifyData[27 + i] >> 8) & 0xFF; + kATADiskModel[i * 2 + 1] = kATAIdentifyData[27 + i] & 0xFF; } - kCurrentDiskModel[40] = '\0'; + kATADiskModel[40] = '\0'; - kout << "Detect: /dev/ata0" << kendl; - - kout << "Drive Model: " << kCurrentDiskModel << kendl; + kout << "Drive Model: " << kATADiskModel << kendl; return true; } @@ -179,7 +177,7 @@ Boolean drv_pio_std_detected(Void) */ SizeT drv_pio_get_sector_count() { - return (kATAData[61] << 16) | kATAData[60]; + return (kATAIdentifyData[61] << 16) | kATAIdentifyData[60]; } /// @brief Get the drive size. |
