summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/HALKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-01 08:39:18 +0200
committerGitHub <noreply@github.com>2025-04-01 08:39:18 +0200
commitf88f6074479c627529559f690bf836960d5a6378 (patch)
treea1acef0bd6286f03197c0e1839e8d41ac5e5538f /dev/kernel/HALKit
parent6849e75f2e95e88b43e2f8804abf1b862e3981cb (diff)
parent2a7a9825fd275d6d999b94614fe87c1d705c7f8f (diff)
Merge pull request #4 from amlel-el-mahrouss/dev
pr/general: mostly minor patches.
Diffstat (limited to 'dev/kernel/HALKit')
-rw-r--r--dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc2
-rw-r--r--dev/kernel/HALKit/AMD64/HalDebugOutput.cc4
-rw-r--r--dev/kernel/HALKit/AMD64/HalKernelMain.cc2
-rw-r--r--dev/kernel/HALKit/AMD64/HalKernelPanic.cc4
-rw-r--r--dev/kernel/HALKit/AMD64/HalUtilsAPI.asm (renamed from dev/kernel/HALKit/AMD64/HalUtils.asm)0
-rw-r--r--dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc146
-rw-r--r--dev/kernel/HALKit/ARM64/HalKernelMain.cc2
-rw-r--r--dev/kernel/HALKit/ARM64/HalKernelPanic.cc4
8 files changed, 87 insertions, 77 deletions
diff --git a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc
index f839884e..10361d8e 100644
--- a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc
+++ b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc
@@ -11,7 +11,7 @@
#include <KernelKit/BinaryMutex.h>
#include <KernelKit/ProcessScheduler.h>
#include <KernelKit/Timer.h>
-#include <modules/CoreGfx/TextMgr.h>
+#include <modules/CoreGfx/TextGfx.h>
#include <NewKit/KernelPanic.h>
#include <KernelKit/HardwareThreadScheduler.h>
diff --git a/dev/kernel/HALKit/AMD64/HalDebugOutput.cc b/dev/kernel/HALKit/AMD64/HalDebugOutput.cc
index 9bd45efe..e79b6b09 100644
--- a/dev/kernel/HALKit/AMD64/HalDebugOutput.cc
+++ b/dev/kernel/HALKit/AMD64/HalDebugOutput.cc
@@ -8,8 +8,8 @@
#include <KernelKit/DebugOutput.h>
#include <NewKit/Utils.h>
#include <NewKit/New.h>
-#include <modules/CoreGfx/FBMgr.h>
-#include <modules/CoreGfx/TextMgr.h>
+#include <modules/CoreGfx/CoreGfx.h>
+#include <modules/CoreGfx/TextGfx.h>
namespace Kernel
{
diff --git a/dev/kernel/HALKit/AMD64/HalKernelMain.cc b/dev/kernel/HALKit/AMD64/HalKernelMain.cc
index 0371bde4..f4dbc16e 100644
--- a/dev/kernel/HALKit/AMD64/HalKernelMain.cc
+++ b/dev/kernel/HALKit/AMD64/HalKernelMain.cc
@@ -12,7 +12,7 @@
#include <modules/ACPI/ACPIFactoryInterface.h>
#include <NetworkKit/IPC.h>
#include <CFKit/Property.h>
-#include <modules/CoreGfx/TextMgr.h>
+#include <modules/CoreGfx/TextGfx.h>
EXTERN_C Kernel::VoidPtr kInterruptVectorTable[];
EXTERN_C Kernel::VoidPtr mp_user_switch_proc;
diff --git a/dev/kernel/HALKit/AMD64/HalKernelPanic.cc b/dev/kernel/HALKit/AMD64/HalKernelPanic.cc
index 770fac2b..3703692c 100644
--- a/dev/kernel/HALKit/AMD64/HalKernelPanic.cc
+++ b/dev/kernel/HALKit/AMD64/HalKernelPanic.cc
@@ -11,8 +11,8 @@
#include <NewKit/KString.h>
#include <FirmwareKit/Handover.h>
#include <KernelKit/FileMgr.h>
-#include <modules/CoreGfx/FBMgr.h>
-#include <modules/CoreGfx/TextMgr.h>
+#include <modules/CoreGfx/CoreGfx.h>
+#include <modules/CoreGfx/TextGfx.h>
#include <NewKit/Utils.h>
/* Each error code is attributed with an ID, which will prompt a string onto the
diff --git a/dev/kernel/HALKit/AMD64/HalUtils.asm b/dev/kernel/HALKit/AMD64/HalUtilsAPI.asm
index ab639992..ab639992 100644
--- a/dev/kernel/HALKit/AMD64/HalUtils.asm
+++ b/dev/kernel/HALKit/AMD64/HalUtilsAPI.asm
diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
index 7dac018d..e5f10db3 100644
--- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
+++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
@@ -77,16 +77,26 @@ STATIC Void drv_compute_disk_ahci() noexcept
static UInt8 identify_data[kSzIdent] ATTRIBUTE(aligned(4096)) = {0};
HAL::mm_map_page((void*)mib_cast(1), (void*)mib_cast(1), HAL::kMMFlagsWr);
-
+
rt_set_memory(identify_data, 0, kSzIdent);
/// Send AHCI command for identification.
drv_std_input_output_ahci<NO, YES, YES>(0, identify_data, kAHCISectorSize, kSzIdent);
/// Extract 48-bit LBA.
- kSATASectorCount = (identify_data[61] << 16) | identify_data[60];
+
+ UInt64 lba48_sectors = 0;
+ lba48_sectors |= (UInt64)identify_data[100];
+ lba48_sectors |= (UInt64)identify_data[101] << 16;
+ lba48_sectors |= (UInt64)identify_data[102] << 32;
+
+ if (lba48_sectors == 0)
+ kSATASectorCount = (identify_data[61] << 16) | identify_data[60];
+ else
+ kSATASectorCount = lba48_sectors;
/// Show what we got.
+
kout << "Disk Model: " << kCurrentDiskModel << kendl;
kout << "Disk Size: " << number(drv_get_size()) << kendl;
kout << "Disk Sector Count: " << number(kSATASectorCount) << kendl;
@@ -142,7 +152,7 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz
MUST_PASS(command_header);
- constexpr UInt32 kMaxPRDSize = 0x400000;
+ constexpr const UInt32 kMaxPRDSize = mib_cast(4);
command_header->Cfl = sizeof(FisRegH2D) / sizeof(UInt32);
command_header->Write = Write;
@@ -392,6 +402,71 @@ Bool drv_std_detected_ahci()
return kSATADev.DeviceId() != (UShort)PCI::PciConfigKind::Invalid && kSATADev.Bar(kSATABar5) != 0;
}
+// ================================================================================================
+
+//
+// This applies only if we compile with AHCI as a default disk driver.
+//
+
+// ================================================================================================
+
+#ifdef __AHCI__
+
+////////////////////////////////////////////////////
+///
+////////////////////////////////////////////////////
+Void drv_std_write(UInt64 lba, Char* buffer, SizeT sector_sz, SizeT size_buffer)
+{
+ drv_std_input_output_ahci<YES, YES, NO>(lba, reinterpret_cast<UInt8*>(buffer), sector_sz, size_buffer);
+}
+
+////////////////////////////////////////////////////
+///
+////////////////////////////////////////////////////
+Void drv_std_read(UInt64 lba, Char* buffer, SizeT sector_sz, SizeT size_buffer)
+{
+ drv_std_input_output_ahci<NO, YES, NO>(lba, reinterpret_cast<UInt8*>(buffer), sector_sz, size_buffer);
+}
+
+////////////////////////////////////////////////////
+///
+////////////////////////////////////////////////////
+Bool drv_std_init(UInt16& pi)
+{
+ BOOL atapi = NO;
+ return drv_std_init_ahci(pi, atapi);
+}
+
+////////////////////////////////////////////////////
+///
+////////////////////////////////////////////////////
+Bool drv_std_detected(Void)
+{
+ return drv_std_detected_ahci();
+}
+
+////////////////////////////////////////////////////
+/**
+ @brief Gets the number of sectors inside the drive.
+ @return Sector size in bytes.
+ */
+////////////////////////////////////////////////////
+SizeT drv_get_sector_count()
+{
+ return drv_get_sector_count_ahci();
+}
+
+////////////////////////////////////////////////////
+/// @brief Get the drive size.
+/// @return Disk size in bytes.
+////////////////////////////////////////////////////
+SizeT drv_get_size()
+{
+ return drv_get_size_ahci();
+}
+
+#endif // ifdef __AHCI__
+
namespace Kernel
{
/// @brief Initialize an AHCI device (StorageKit)
@@ -471,68 +546,3 @@ namespace Kernel
return ErrorOr<AHCIDeviceInterface>(device);
}
} // namespace Kernel
-
-// ================================================================================================
-
-//
-// This applies only if we compile with AHCI as a default disk driver.
-//
-
-// ================================================================================================
-
-#ifdef __AHCI__
-
-////////////////////////////////////////////////////
-///
-////////////////////////////////////////////////////
-Void drv_std_write(UInt64 lba, Char* buffer, SizeT sector_sz, SizeT size_buffer)
-{
- drv_std_input_output_ahci<YES, YES, NO>(lba, reinterpret_cast<UInt8*>(buffer), sector_sz, size_buffer);
-}
-
-////////////////////////////////////////////////////
-///
-////////////////////////////////////////////////////
-Void drv_std_read(UInt64 lba, Char* buffer, SizeT sector_sz, SizeT size_buffer)
-{
- drv_std_input_output_ahci<NO, YES, NO>(lba, reinterpret_cast<UInt8*>(buffer), sector_sz, size_buffer);
-}
-
-////////////////////////////////////////////////////
-///
-////////////////////////////////////////////////////
-Bool drv_std_init(UInt16& pi)
-{
- BOOL atapi = NO;
- return drv_std_init_ahci(pi, atapi);
-}
-
-////////////////////////////////////////////////////
-///
-////////////////////////////////////////////////////
-Bool drv_std_detected(Void)
-{
- return drv_std_detected_ahci();
-}
-
-////////////////////////////////////////////////////
-/**
- @brief Gets the number of sectors inside the drive.
- @return Sector size in bytes.
- */
-////////////////////////////////////////////////////
-SizeT drv_get_sector_count()
-{
- return drv_get_sector_count_ahci();
-}
-
-////////////////////////////////////////////////////
-/// @brief Get the drive size.
-/// @return Disk size in bytes.
-////////////////////////////////////////////////////
-SizeT drv_get_size()
-{
- return drv_get_size_ahci();
-}
-
-#endif // ifdef __AHCI__
diff --git a/dev/kernel/HALKit/ARM64/HalKernelMain.cc b/dev/kernel/HALKit/ARM64/HalKernelMain.cc
index 14781151..d9f3eb85 100644
--- a/dev/kernel/HALKit/ARM64/HalKernelMain.cc
+++ b/dev/kernel/HALKit/ARM64/HalKernelMain.cc
@@ -5,7 +5,7 @@
------------------------------------------- */
#include <ArchKit/ArchKit.h>
-#include <modules/CoreGfx/FBMgr.h>
+#include <modules/CoreGfx/CoreGfx.h>
#include <FirmwareKit/Handover.h>
#include <KernelKit/FileMgr.h>
#include <KernelKit/MemoryMgr.h>
diff --git a/dev/kernel/HALKit/ARM64/HalKernelPanic.cc b/dev/kernel/HALKit/ARM64/HalKernelPanic.cc
index 4a632564..1e008c0f 100644
--- a/dev/kernel/HALKit/ARM64/HalKernelPanic.cc
+++ b/dev/kernel/HALKit/ARM64/HalKernelPanic.cc
@@ -11,8 +11,8 @@
#include <NewKit/KString.h>
#include <FirmwareKit/Handover.h>
#include <KernelKit/FileMgr.h>
-#include <modules/CoreGfx/FBMgr.h>
-#include <modules/CoreGfx/TextMgr.h>
+#include <modules/CoreGfx/CoreGfx.h>
+#include <modules/CoreGfx/TextGfx.h>
#include <NewKit/Utils.h>
/* Each error code is attributed with an ID, which will prompt a string onto the