diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-02-07 13:43:24 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-02-07 13:43:24 +0100 |
| commit | fb35c7b211920db07079bd5948e54d0f4347076d (patch) | |
| tree | 2a7ab0eb567aa857bc784302061700dafec909c0 /dev | |
| parent | f55c8992158bd9d322df6acda026c4e2660de854 (diff) | |
ADD: Major tweaks and improvements on the kernel product.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/Kernel/HALKit/AMD64/HalKernelMain.cc | 2 | ||||
| -rw-r--r-- | dev/Kernel/HALKit/AMD64/HalKernelPanic.cc | 32 | ||||
| -rw-r--r-- | dev/Kernel/HALKit/AMD64/Storage/SATA.cc | 35 | ||||
| -rw-r--r-- | dev/Mod/AHCI/AHCI.h | 8 |
4 files changed, 17 insertions, 60 deletions
diff --git a/dev/Kernel/HALKit/AMD64/HalKernelMain.cc b/dev/Kernel/HALKit/AMD64/HalKernelMain.cc index 3851921c..a15a6984 100644 --- a/dev/Kernel/HALKit/AMD64/HalKernelMain.cc +++ b/dev/Kernel/HALKit/AMD64/HalKernelMain.cc @@ -82,6 +82,8 @@ EXTERN_C void hal_init_platform( gdt_reg.Base = reinterpret_cast<Kernel::UIntPtr>(kGDTArray); gdt_reg.Limit = (sizeof(Kernel::HAL::Detail::NE_GDT_ENTRY) * kGDTEntriesCount) - 1; + FB::fb_clear_video(); + //! GDT will load hal_read_init after it successfully loads the segments. Kernel::HAL::GDTLoader gdt_loader; gdt_loader.Load(gdt_reg); diff --git a/dev/Kernel/HALKit/AMD64/HalKernelPanic.cc b/dev/Kernel/HALKit/AMD64/HalKernelPanic.cc index 9ff19744..6a4284ec 100644 --- a/dev/Kernel/HALKit/AMD64/HalKernelPanic.cc +++ b/dev/Kernel/HALKit/AMD64/HalKernelPanic.cc @@ -40,31 +40,9 @@ namespace Kernel auto y = 10; auto x = 10; - Char* message_apicid = new Char[128]; - rt_set_memory(message_apicid, 0, 128); - - rt_copy_memory((VoidPtr) "panic id: ", message_apicid, rt_string_len("panic id: ")); - rt_to_string(message_apicid + rt_string_len("panic id: "), (UIntPtr)id, 10); - - fb_render_string(message_apicid, y, x, panic_text); - - y += 10; - - fb_render_string((message ? message : "message: panic raised, going nowhere after this!"), y, x, panic_text); - - y += 10; - - Char* message_cr2 = new Char[128]; - rt_set_memory(message_cr2, 0, 128); - - rt_copy_memory((VoidPtr) "cr2: ", message_cr2, rt_string_len("cr2: ")); - rt_to_string(message_cr2 + rt_string_len("cr2: "), (UIntPtr)hal_read_cr2(), 10); - - fb_render_string(message_cr2, y, x, panic_text); - - y += 10; - - fb_clear(); + kout << "Kernel_Panic: " << message << endl; + kout << "Kernel_Panic_ID: " << hex_number(id) << endl; + kout << "Kernel_Panic_CR2:" << hex_number((UIntPtr)hal_read_cr2()) << endl; RecoveryFactory::Recover(); } @@ -81,8 +59,8 @@ namespace Kernel { if (!expr) { - kout << "FAILED: FILE: " << file << endl; - kout << "FAILED: LINE: " << line << endl; + kout << "Kernel_Panic_File: " << file << endl; + kout << "Kernel_Panic_Line: " << line << endl; ke_panic(RUNTIME_CHECK_FAILED, file); // Runtime Check failed } diff --git a/dev/Kernel/HALKit/AMD64/Storage/SATA.cc b/dev/Kernel/HALKit/AMD64/Storage/SATA.cc index e4028703..e7971e19 100644 --- a/dev/Kernel/HALKit/AMD64/Storage/SATA.cc +++ b/dev/Kernel/HALKit/AMD64/Storage/SATA.cc @@ -67,6 +67,8 @@ static Kernel::Void drv_calculate_disk_geometry() noexcept kout << "Disk Size: " << Kernel::number(drv_get_size()) << endl; kout << "Highest Disk LBA: " << Kernel::number(kCurrentDiskSectorCount) << endl; + + while(1); } /// @brief Initializes an AHCI disk. @@ -200,8 +202,8 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff MUST_PASS(command_table); - command_table->Prdt[0].Dba = ((Kernel::UInt32)(Kernel::UInt64)buffer); - command_table->Prdt[0].Dbau = (((Kernel::UInt64)buffer >> 32)); + command_table->Prdt[0].Dba = ((Kernel::UInt32)(Kernel::UInt64)Kernel::HAL::hal_get_phys_address(buffer)); + command_table->Prdt[0].Dbau = (((Kernel::UInt64)Kernel::HAL::hal_get_phys_address(buffer) >> 32)); command_table->Prdt[0].Dbc = ((size_buffer)-1); command_table->Prdt[0].InterruptBit = 1; @@ -219,9 +221,6 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff if (Identify) h2d_fis->Command = kAHCICmdIdentify; - h2d_fis->FeatureLow = h2d_fis->FeatureLow | 1; - h2d_fis->FeatureLow = h2d_fis->FeatureLow | (1 << 2); - h2d_fis->Lba0 = (lba & 0xFF); h2d_fis->Lba1 = (lba >> 8) & 0xFF; h2d_fis->Lba2 = (lba >> 16) & 0xFF; @@ -238,31 +237,13 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff while ((kSATAPort->Ports[kSATAPortIdx].Tfd & (kAhciSRBsy | kAhciSRDrq))) { - kout << "Waiting for the tfd to be ready...\r"; + kout << "Waiting for the TFD to be ready...\r"; } if (kSATAPort->Is & kHBAErrTaskFile) Kernel::ke_panic(RUNTIME_CHECK_BAD_BEHAVIOR, "AHCI Read disk failure, faulty component."); - FisDmaSetup* setup_fis = new FisDmaSetup(); - Kernel::rt_set_memory(reinterpret_cast<Kernel::VoidPtr>(setup_fis), 0, sizeof(FisDmaSetup)); - - kSATAPort->Ports[kSATAPortIdx].Cmd &= ~kHBAPxCmdST; - kSATAPort->Ports[kSATAPortIdx].Cmd &= ~kHBAPxCmdFre; - - while (kSATAPort->Ports[kSATAPortIdx].Cmd & kHBAPxCmdCR) - kout << "Waiting for command engine to stop...\r"; - - kSATAPort->Ports[kSATAPortIdx].Fb = (Kernel::UInt32)((Kernel::UInt64)setup_fis); - kSATAPort->Ports[kSATAPortIdx].Fbu = (Kernel::UInt32)((Kernel::UInt64)setup_fis >> 32); - - kSATAPort->Ports[kSATAPortIdx].Cmd |= kHBAPxCmdFre; - kSATAPort->Ports[kSATAPortIdx].Cmd |= kHBAPxCmdST; - - if (kSATAPort->Is & (1 << 30)) - kSATAPort->Is = (Kernel::UInt32)-1; - - kSATAPort->Ports[kSATAPortIdx].Ci = (1 << slot); + kSATAPort->Ports[kSATAPortIdx].Ci |= (1 << slot); while (YES) { @@ -273,7 +254,6 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff Kernel::ke_panic(RUNTIME_CHECK_BAD_BEHAVIOR, "AHCI Read disk failure, faulty component."); kout << "Waiting for the slot to be ready:\r"; - kout << "DTD: " << Kernel::hex_number(setup_fis->DTD) << endl; kout << "CI: " << Kernel::hex_number(kSATAPort->Ports[kSATAPortIdx].Ci) << endl; kout << "TFD: " << Kernel::hex_number(kSATAPort->Ports[kSATAPortIdx].Tfd) << endl; } @@ -285,9 +265,6 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff delete command_table; command_table = nullptr; - - delete setup_fis; - setup_fis = nullptr; } /*** diff --git a/dev/Mod/AHCI/AHCI.h b/dev/Mod/AHCI/AHCI.h index 612a21e6..43fe4f0b 100644 --- a/dev/Mod/AHCI/AHCI.h +++ b/dev/Mod/AHCI/AHCI.h @@ -95,7 +95,7 @@ typedef struct FisRegD2H final Kernel::UInt8 Reserved1 : 1; // Reserved Kernel::UInt8 Status; // Status register - Kernel::UInt8 Rrror; // Error register + Kernel::UInt8 Error; // Error register // DWORD 1 Kernel::UInt8 Lba0; // LBA low register, 7:0 @@ -183,7 +183,7 @@ typedef struct FisDmaSetup final Kernel::UInt8 Reserved1[2]; // Reserved // DWORD 1&2 - Kernel::UInt64 DmaBufferId; // DMA Buffer Identifier. Used to Identify DMA buffer in + volatile Kernel::UInt64 DmaBufferId; // DMA Buffer Identifier. Used to Identify DMA buffer in // host memory. SATA Spec says host specific and not in // Spec. Trying AHCI spec might work. @@ -243,7 +243,7 @@ typedef struct HbaPort final Kernel::UInt32 Serr; // 0x30, SATA error (SCR1:SError) Kernel::UInt32 Sact; // 0x34, SATA active (SCR3:SActive) Kernel::UInt32 Ci; // 0x38, command issue - Kernel::UInt32 Sntf; // 0x20, SATA notification (SCR4:SNotification) + Kernel::UInt32 Sntf; // 0x3C, SATA notification (SCR4:SNotification) Kernel::UInt32 Fbs; // 0x40, FIS-based switch control Kernel::UInt32 Reserved1[11]; // 0x44 ~ 0x6F, Reserved Kernel::UInt32 Vendor[4]; // 0x70 ~ 0x7F, vendor specific @@ -328,7 +328,7 @@ typedef struct HbaCmdTbl final Kernel::UInt8 Cfis[64]; // Command FIS Kernel::UInt8 Acmd[16]; // ATAPI command, 12 or 16 bytes Kernel::UInt8 Rsv[48]; // Reserved - struct HbaPrdtEntry Prdt[1]; // Physical region descriptor table entries, 0 ~ 65535 + struct HbaPrdtEntry Prdt[]; // Physical region descriptor table entries, 0 ~ 65535 } HbaCmdTbl; /// @brief Initializes an AHCI disk. |
