From cb2f383f45dda8d1cdcef0b87fe4c70243659701 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sun, 27 Apr 2025 17:30:36 +0200 Subject: dev, kernel: AHCI, HeFS filesystem, SysChk, and BootSATA improvements. what? - AHCI now writes to disk, forgot to do it. - Codebase's architecutre has been used to reuse the Generic+AHCI driver in SysChk for AHCI. (tradeoff is 256K in size instead of 36K) - DriveMgr now detects EPM. - And HeFS is still being worked on. Signed-off-by: Amlal --- dev/boot/BootKit/BootKit.h | 12 +---- dev/boot/BootKit/HW/SATA.h | 10 +++- dev/boot/modules/SysChk/SysChk.cc | 14 +++--- dev/boot/modules/SysChk/amd64-ahci-epm.json | 12 +++-- dev/boot/modules/SysChk/amd64-ahci-gpt.json | 15 ++++-- dev/boot/modules/SysChk/amd64-pio-gpt.json | 2 +- dev/boot/src/HEL/AMD64/BootATA.cc | 4 +- dev/boot/src/HEL/AMD64/BootPlatform.cc | 10 +--- dev/boot/src/HEL/AMD64/BootSATA.cc | 62 +++++++++++++++++++++++++ dev/boot/src/HEL/ARM64/BootPlatform.cc | 2 +- dev/kernel/FSKit/HeFS.h | 2 +- dev/kernel/FirmwareKit/EFI/API.h | 4 +- dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc | 38 +++++++-------- dev/kernel/HALKit/AMD64/HalKernelMain.cc | 4 ++ dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc | 45 +++++++++++------- dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc | 13 ++++-- dev/kernel/StorageKit/DMA.h | 6 +-- dev/kernel/src/FS/HeFS.cc | 14 +++--- dev/kernel/src/Utils.cc | 7 +++ 19 files changed, 180 insertions(+), 96 deletions(-) (limited to 'dev') diff --git a/dev/boot/BootKit/BootKit.h b/dev/boot/BootKit/BootKit.h index aa7dde85..7a25e2a5 100644 --- a/dev/boot/BootKit/BootKit.h +++ b/dev/boot/BootKit/BootKit.h @@ -170,7 +170,7 @@ EXTERN_C UInt8 rt_in8(UInt16 port); EXTERN_C UInt16 In16(UInt16 port); EXTERN_C UInt32 rt_in32(UInt16 port); -EXTERN_C void rt_hlt(); +EXTERN_C void rt_halt(); EXTERN_C void rt_cli(); EXTERN_C void rt_sti(); EXTERN_C void rt_cld(); @@ -256,16 +256,6 @@ class BDiskFormatFactory final { template inline Boolean BDiskFormatFactory::Format(const Char* part_name) { #if defined(BOOTZ_EPM_SUPPORT) - /// @note A catalog roughly equal to a sector in NeFS terms. - constexpr auto kMinimumDiskSize = kNeFSMinimumDiskSize; // at minimum. - - /// @note also look at EPM headers, for free part blocks. (only applies if EPM or vEPM is used) - - if (fDiskDev.GetDiskSize() < kMinimumDiskSize) { - Boot::ThrowError(L"Drive-Too-Tiny", L"Can't format a EPM partition here."); - return false; - } - EPM_PART_BLOCK epm_boot{}; const auto kFsName = "HeFS"; diff --git a/dev/boot/BootKit/HW/SATA.h b/dev/boot/BootKit/HW/SATA.h index 7e84c061..5c70c18c 100644 --- a/dev/boot/BootKit/HW/SATA.h +++ b/dev/boot/BootKit/HW/SATA.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include @@ -20,14 +21,19 @@ class BootDeviceSATA final { Kernel::SizeT mBase{1024}; Kernel::Boolean mErr{false}; Kernel::Boolean mDetected{false}; + Kernel::SizeT mSize{0}; operator bool() { return !this->mErr; } }; operator bool() { return this->Leak().mDetected; } - BootDeviceSATA& Read(Kernel::WideChar* Buf, const Kernel::SizeT SecCount); - BootDeviceSATA& Write(Kernel::WideChar* Buf, const Kernel::SizeT SecCount); + SizeT GetDiskSize() { return drv_get_size(); } + + constexpr static auto kSectorSize = kAHCISectorSize; + + BootDeviceSATA& Read(Boot::CharacterTypeUTF8* Buf, const Kernel::SizeT SecCount); + BootDeviceSATA& Write(Boot::CharacterTypeUTF8* Buf, const Kernel::SizeT SecCount); SATATrait& Leak(); diff --git a/dev/boot/modules/SysChk/SysChk.cc b/dev/boot/modules/SysChk/SysChk.cc index a3697bb1..05ac6da0 100644 --- a/dev/boot/modules/SysChk/SysChk.cc +++ b/dev/boot/modules/SysChk/SysChk.cc @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -26,17 +27,16 @@ #endif // !kMachineModel EXTERN_C Int32 SysChkModuleMain(Kernel::HEL::BootInfoHeader* handover) { -#if defined(__ATA_PIO__) fw_init_efi((EfiSystemTable*) handover->f_FirmwareCustomTables[1]); +#if defined(__ATA_PIO__) Boot::BDiskFormatFactory partition_factory; - +#elif defined(__AHCI__) + Boot::BDiskFormatFactory partition_factory; +#endif if (partition_factory.IsPartitionValid()) return kEfiOk; - return partition_factory.Format(kMachineModel) == YES; -#else - NE_UNUSED(handover); + auto ret = partition_factory.Format(kMachineModel) == YES; - return kEfiOk; -#endif + return ret; } diff --git a/dev/boot/modules/SysChk/amd64-ahci-epm.json b/dev/boot/modules/SysChk/amd64-ahci-epm.json index 1a82cf55..3c56cfe8 100644 --- a/dev/boot/modules/SysChk/amd64-ahci-epm.json +++ b/dev/boot/modules/SysChk/amd64-ahci-epm.json @@ -10,7 +10,13 @@ "../../src/HEL/AMD64/BootAPI.S", "../../src/BootTextWriter.cc", "../../src/BootSupport.cc", - "../../src/New+Delete.cc" + "../../src/New+Delete.cc", + "../../../kernel/HALKit/AMD64/PCI/*.cc", + "../../../kernel/HALKit/AMD64/Storage/*.cc", + "../../../kernel/src/Storage/*.cc", + "../../../kernel/HALKit/AMD64/*.cc", + "../../../kernel/HALKit/AMD64/*.s", + "../../../kernel/src/*.cc" ], "output_name": "chk.efi", "compiler_flags": [ @@ -22,11 +28,11 @@ ], "cpp_macros": [ "__NEOSKRNL__", - "__BOOTZ__", - "__BOOTZ_STANDALONE__", "__NE_AMD64__", "__AHCI__", + "__SYSCHK__", "BOOTZ_EPM_SUPPORT", + "__NE_MODULAR_KERNEL_COMPONENTS__", "kChkVersionHighest=0x0100", "kChkVersionLowest=0x0100", "kChkVersion=0x0100" diff --git a/dev/boot/modules/SysChk/amd64-ahci-gpt.json b/dev/boot/modules/SysChk/amd64-ahci-gpt.json index cb538eed..80bb433e 100644 --- a/dev/boot/modules/SysChk/amd64-ahci-gpt.json +++ b/dev/boot/modules/SysChk/amd64-ahci-gpt.json @@ -10,7 +10,13 @@ "../../src/HEL/AMD64/BootAPI.S", "../../src/BootTextWriter.cc", "../../src/BootSupport.cc", - "../../src/New+Delete.cc" + "../../src/New+Delete.cc", + "../../../kernel/HALKit/AMD64/PCI/*.cc", + "../../../kernel/HALKit/AMD64/Storage/*.cc", + "../../../kernel/src/Storage/*.cc", + "../../../kernel/HALKit/AMD64/*.cc", + "../../../kernel/HALKit/AMD64/*.s", + "../../../kernel/src/*.cc" ], "output_name": "chk.efi", "compiler_flags": [ @@ -22,12 +28,11 @@ ], "cpp_macros": [ "__NEOSKRNL__", - "__BOOTZ__", - "__BOOTZ_STANDALONE__", "__NE_AMD64__", "__AHCI__", - "__NE_VEPM__", - "BOOTZ_VEPM_SUPPORT", + "__SYSCHK__", + "BOOTZ_GPT_SUPPORT", + "__NE_MODULAR_KERNEL_COMPONENTS__", "kChkVersionHighest=0x0100", "kChkVersionLowest=0x0100", "kChkVersion=0x0100" diff --git a/dev/boot/modules/SysChk/amd64-pio-gpt.json b/dev/boot/modules/SysChk/amd64-pio-gpt.json index 21c81667..b1a4d38b 100644 --- a/dev/boot/modules/SysChk/amd64-pio-gpt.json +++ b/dev/boot/modules/SysChk/amd64-pio-gpt.json @@ -33,7 +33,7 @@ "__NE_AMD64__", "__ATA_PIO__", "__NE_VEPM__", - "BOOTZ_VEPM_SUPPORT", + "BOOTZ_GPT_SUPPORT", "kChkVersionHighest=0x0100", "kChkVersionLowest=0x0100", "kChkVersion=0x0100" diff --git a/dev/boot/src/HEL/AMD64/BootATA.cc b/dev/boot/src/HEL/AMD64/BootATA.cc index 693513e0..7557f941 100644 --- a/dev/boot/src/HEL/AMD64/BootATA.cc +++ b/dev/boot/src/HEL/AMD64/BootATA.cc @@ -19,12 +19,12 @@ #include #include +#define kATADataLen (256) + /// bugs: 0 using namespace Boot; -#define kATADataLen (256) - static Boolean kATADetected = false; static UInt16 kATAData[kATADataLen] = {0}; diff --git a/dev/boot/src/HEL/AMD64/BootPlatform.cc b/dev/boot/src/HEL/AMD64/BootPlatform.cc index 8b4d57c4..4cc783d6 100644 --- a/dev/boot/src/HEL/AMD64/BootPlatform.cc +++ b/dev/boot/src/HEL/AMD64/BootPlatform.cc @@ -13,7 +13,7 @@ using namespace Boot; -EXTERN_C void rt_hlt() { +EXTERN_C void rt_halt() { asm volatile("hlt"); } @@ -33,12 +33,4 @@ EXTERN_C void rt_std() { asm volatile("std"); } -#else - -#include - -void rt_hlt() { - Kernel::HAL::rt_halt(); -} - #endif // __BOOTZ_STANDALONE__ diff --git a/dev/boot/src/HEL/AMD64/BootSATA.cc b/dev/boot/src/HEL/AMD64/BootSATA.cc index ef5d2096..783acb4c 100644 --- a/dev/boot/src/HEL/AMD64/BootSATA.cc +++ b/dev/boot/src/HEL/AMD64/BootSATA.cc @@ -18,3 +18,65 @@ #include #include #include + +#include +#include + +#if defined(__AHCI__) && defined(__SYSCHK__) + +using namespace Boot; + +/*** + * + * + * @brief SATA Device class. + * + * + */ + +/** + * @brief ATA Device constructor. + * @param void none. + */ +BootDeviceSATA::BootDeviceSATA() noexcept { + UInt16 pi = 0u; + drv_std_init(pi); +} + +/** + @brief Read Buf from disk + @param Sz Sector size + @param Buf buffer +*/ +BootDeviceSATA& BootDeviceSATA::Read(CharacterTypeUTF8* Buf, SizeT SectorSz) { + NE_UNUSED(Buf); + NE_UNUSED(SectorSz); + + drv_std_read(mTrait.mBase, Buf, SectorSz, mTrait.mSize); + + return *this; +} + +/** + @brief Write Buf into disk + @param Sz Sector size + @param Buf buffer +*/ +BootDeviceSATA& BootDeviceSATA::Write(CharacterTypeUTF8* Buf, SizeT SectorSz) { + NE_UNUSED(Buf); + NE_UNUSED(SectorSz); + + drv_std_write(mTrait.mBase, Buf, SectorSz, mTrait.mSize); + + return *this; +} + +/** + * @brief ATA trait getter. + * @return BootDeviceSATA::ATATrait& the drive config. + */ +BootDeviceSATA::SATATrait& BootDeviceSATA::Leak() { + return mTrait; +} + +#endif \ No newline at end of file diff --git a/dev/boot/src/HEL/ARM64/BootPlatform.cc b/dev/boot/src/HEL/ARM64/BootPlatform.cc index 0f6a738f..683245fb 100644 --- a/dev/boot/src/HEL/ARM64/BootPlatform.cc +++ b/dev/boot/src/HEL/ARM64/BootPlatform.cc @@ -12,7 +12,7 @@ using namespace Boot; -EXTERN_C void rt_hlt() { +EXTERN_C void rt_halt() { while (Yes); } diff --git a/dev/kernel/FSKit/HeFS.h b/dev/kernel/FSKit/HeFS.h index fd462b17..bdc8a338 100644 --- a/dev/kernel/FSKit/HeFS.h +++ b/dev/kernel/FSKit/HeFS.h @@ -164,7 +164,7 @@ struct PACKED ALIGN(8) HEFS_INDEX_NODE final { enum { kHeFSInvalidColor = 0, - kHeFSRed = 100, + kHeFSRed = 100, kHeFSBlack, kHeFSColorCount, }; diff --git a/dev/kernel/FirmwareKit/EFI/API.h b/dev/kernel/FirmwareKit/EFI/API.h index 0b937477..47b9e4d1 100644 --- a/dev/kernel/FirmwareKit/EFI/API.h +++ b/dev/kernel/FirmwareKit/EFI/API.h @@ -29,7 +29,7 @@ inline EfiSystemTable* ST = nullptr; inline EfiBootServices* BS = nullptr; EXTERN_C void rt_cli(); -EXTERN_C void rt_hlt(); +EXTERN_C void rt_halt(); namespace Boot { /// @brief Halt and clear interrupts. @@ -37,7 +37,7 @@ namespace Boot { inline Void Stop() noexcept { while (YES) { rt_cli(); - rt_hlt(); + rt_halt(); } } diff --git a/dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc b/dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc index e6d57be2..2fb6ad4c 100644 --- a/dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc +++ b/dev/kernel/HALKit/AMD64/HalDescriptorLoader.cc @@ -15,26 +15,20 @@ namespace Detail { STATIC ::Kernel::Detail::AMD64::InterruptDescriptorAMD64 kInterruptVectorTable[kKernelIdtSize] = {}; -#if 0 - STATIC void hal_set_irq_mask(UInt8 irql) [[maybe_unused]] - { - UInt16 port; - UInt8 value; - - if (irql < 8) - { - port = kPICData; - } - else - { - port = kPIC2Data; - irql -= 8; - } - - value = rt_in8(port) | (1 << irql); - rt_out8(port, value); - } -#endif // make gcc shut up + STATIC ATTRIBUTE(unused) void hal_set_irq_mask(UInt8 irql) [[maybe_unused]] { + UInt16 port; + UInt8 value; + + if (irql < 8) { + port = kPICData; + } else { + port = kPIC2Data; + irql -= 8; + } + + value = rt_in8(port) | (1 << irql); + rt_out8(port, value); + } STATIC void hal_clear_irq_mask(UInt8 irql) [[maybe_unused]] { UInt16 port; @@ -70,7 +64,9 @@ namespace Detail { /// @param gdt /// @return Void GDTLoader::Load(Register64& gdt) { +#ifndef __NE_MODULAR_KERNEL_COMPONENTS__ hal_load_gdt(gdt); +#endif // __NE_MODULAR_KERNEL_COMPONENTS__ } Void IDTLoader::Load(Register64& idt) { @@ -98,7 +94,9 @@ Void IDTLoader::Load(Register64& idt) { Detail::hal_enable_pit(kPITTickForScheduler); +#ifndef __NE_MODULAR_KERNEL_COMPONENTS__ hal_load_idt(idt); +#endif // __NE_MODULAR_KERNEL_COMPONENTS__ rt_sti(); } diff --git a/dev/kernel/HALKit/AMD64/HalKernelMain.cc b/dev/kernel/HALKit/AMD64/HalKernelMain.cc index 8f4b55cb..5a826a9d 100644 --- a/dev/kernel/HALKit/AMD64/HalKernelMain.cc +++ b/dev/kernel/HALKit/AMD64/HalKernelMain.cc @@ -17,6 +17,7 @@ #include #include +#ifndef __NE_MODULAR_KERNEL_COMPONENTS__ EXTERN_C Kernel::VoidPtr kInterruptVectorTable[]; STATIC Kernel::Void hal_pre_init_scheduler() noexcept { @@ -105,7 +106,9 @@ EXTERN_C Int32 hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) { EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept { hal_pre_init_scheduler(); +#if defined(__FSKIT_INCLUDES_HEFS__) Kernel::HeFS::fs_init_hefs(); +#endif Kernel::HAL::mp_init_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr); @@ -141,3 +144,4 @@ EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept { ++team_index; } } +#endif // ifndef __NE_MODULAR_KERNEL_COMPONENTS__ \ No newline at end of file diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index fd138513..1591fa56 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -55,11 +55,11 @@ using namespace Kernel; STATIC PCI::Device kSATADev; STATIC HbaMemRef kSATAHba; -STATIC Lba kSATASectorCount = 0UL; -STATIC UInt16 kSATAIndex = 0U; -STATIC Char kCurrentDiskModel[50] = {"GENERIC SATA"}; -STATIC UInt16 kSATAPortsImplemented = 0U; -STATIC ALIGN(4096) UInt8 kIdentifyData[kAHCISectorSize] = {0}; +STATIC Lba kSATASectorCount = 0UL; +STATIC UInt16 kSATAIndex = 0U; +STATIC Char kCurrentDiskModel[50] = {"GENERIC SATA"}; +STATIC UInt16 kSATAPortsImplemented = 0U; +STATIC ALIGN(kib_cast(4)) UInt8 kIdentifyData[kAHCISectorSize] = {0}; template STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz, @@ -153,6 +153,10 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz VoidPtr ptr = Kernel::rtl_dma_alloc(size_buffer, 4096); + if (Write) { + Kernel::rt_copy_memory(buffer, ptr, size_buffer); + } + // Build the PRDT SizeT bytes_remaining = size_buffer; SizeT prdt_index = 0; @@ -160,8 +164,8 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz while (bytes_remaining > 0 && prdt_index < 8) { SizeT chunk_size = bytes_remaining; - if (chunk_size > 8 * 1024) // AHCI recommends ~8 KiB per PRDT - chunk_size = 8 * 1024; + + if (chunk_size > kib_cast(32)) chunk_size = kib_cast(32); command_table->Prdt[prdt_index].Dba = (UInt32) (buffer_phys & 0xFFFFFFFF); command_table->Prdt[prdt_index].Dbau = (UInt32) (buffer_phys >> 32); @@ -170,12 +174,16 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz buffer_phys += chunk_size; bytes_remaining -= chunk_size; + ++prdt_index; } + command_table->Prdt[prdt_index - 1].Ie = YES; + if (bytes_remaining > 0) { kout << "Warning: AHCI PRDT overflow, cannot map full buffer.\r"; err_global_get() = kErrorDisk; + return; } @@ -197,9 +205,10 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz h2d_fis->Lba4 = (lba >> 32) & 0xFF; h2d_fis->Lba5 = (lba >> 40) & 0xFF; + h2d_fis->Device = 0; + if (Identify) { - h2d_fis->Device = 0; // DO NOT set LBAMODE flag - h2d_fis->CountLow = 1; // IDENTIFY always transfers 1 sector + h2d_fis->CountLow = 1; h2d_fis->CountHigh = 0; } else { h2d_fis->Device = kSATALBAMode; @@ -220,12 +229,15 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz if (kSATAHba->Is & kHBAErrTaskFile) { kout << "AHCI Task File Error during I/O.\r"; - + rtl_dma_free(size_buffer); err_global_get() = kErrorDiskIsCorrupted; return; } else { + rtl_dma_flush(ptr, size_buffer); rt_copy_memory(ptr, buffer, size_buffer); + rtl_dma_flush(ptr, size_buffer); + rtl_dma_free(size_buffer); err_global_get() = kErrorSuccess; @@ -289,11 +301,11 @@ STATIC Bool drv_init_command_structures_ahci() { UIntPtr clb_phys = HAL::hal_get_phys_address(clb_mem); - kSATAHba->Ports[kSATAIndex].Clb = (UInt32)(clb_phys & 0xFFFFFFFF); - kSATAHba->Ports[kSATAIndex].Clbu = (UInt32)(clb_phys >> 32); + kSATAHba->Ports[kSATAIndex].Clb = (UInt32) (clb_phys & 0xFFFFFFFF); + kSATAHba->Ports[kSATAIndex].Clbu = (UInt32) (clb_phys >> 32); // Clear it - rt_set_memory(clb_mem, 0, 4096); + rt_set_memory(clb_mem, 0, kib_cast(4)); // For each command slot (up to 32) volatile HbaCmdHeader* header = (volatile HbaCmdHeader*) clb_mem; @@ -302,15 +314,15 @@ STATIC Bool drv_init_command_structures_ahci() { // Allocate 4KiB for Command Table VoidPtr ct_mem = Kernel::rtl_dma_alloc(4096, 128); if (!ct_mem) { - kout << "Failed to allocate CTB memory for slot " << hex_number(i); + (Void)(kout << "Failed to allocate CTB memory for slot " << hex_number(i)); kout << "!\r"; return NO; } UIntPtr ct_phys = HAL::hal_get_phys_address(ct_mem); - header[i].Ctba = (UInt32)(ct_phys & 0xFFFFFFFF); - header[i].Ctbau = (UInt32)(ct_phys >> 32); + header[i].Ctba = (UInt32) (ct_phys & 0xFFFFFFFF); + header[i].Ctbau = (UInt32) (ct_phys >> 32); // Clear the command table rt_set_memory((VoidPtr) ct_mem, 0, 4096); @@ -319,7 +331,6 @@ STATIC Bool drv_init_command_structures_ahci() { return YES; } - /// @brief Initializes an AHCI disk. /// @param pi the amount of ports that have been detected. /// @param atapi reference value, tells whether we should detect ATAPI instead of SATA. diff --git a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc index a7361778..ca3e9ee4 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 UInt16 kATAIdentifyData[kATADataLen] = {0}; +STATIC Boolean kATADetected = false; +STATIC Int32 kATADeviceType ATTRIBUTE(unused) = kATADeviceCount; +STATIC UInt16 kATAIdentifyData[kATADataLen] = {0}; STATIC Kernel::PCI::Device kATADevice; -STATIC Char kATADiskModel[50] = {"GENERIC DMA"}; +STATIC Char kATADiskModel[50] ATTRIBUTE(unused) = {"GENERIC DMA"}; Boolean drv_std_wait_io(UInt16 IO) { for (int i = 0; i < 400; i++) rt_in8(IO + ATA_REG_STATUS); @@ -60,6 +60,11 @@ Void drv_std_select(UInt16 Bus) { } Boolean drv_std_init(UInt16 Bus, UInt8 Drive, UInt16& OutBus, UInt8& OutMaster) { + NE_UNUSED(Bus); + NE_UNUSED(Drive); + NE_UNUSED(OutBus); + NE_UNUSED(OutMaster); + PCI::Iterator iterator(Types::PciDeviceKind::MassStorageController); for (SizeT device_index = 0; device_index < NE_BUS_COUNT; ++device_index) { diff --git a/dev/kernel/StorageKit/DMA.h b/dev/kernel/StorageKit/DMA.h index 17dda29a..c572ffa3 100644 --- a/dev/kernel/StorageKit/DMA.h +++ b/dev/kernel/StorageKit/DMA.h @@ -52,15 +52,13 @@ inline VoidPtr rtl_dma_alloc(SizeT size, SizeT align) { } inline Void rtl_dma_free(SizeT size) { - if (!size) - return; + if (!size) return; kDmaPoolPtr = (UInt8*) (kDmaPoolPtr - size); } inline Void rtl_dma_flush(Void* ptr, SizeT size_buffer) { - if (ptr > (Void*)(DMA_POOL_START + DMA_POOL_SIZE)) - { + if (ptr > (Void*) (DMA_POOL_START + DMA_POOL_SIZE)) { return; } diff --git a/dev/kernel/src/FS/HeFS.cc b/dev/kernel/src/FS/HeFS.cc index eb6e6fc1..a27712e3 100644 --- a/dev/kernel/src/FS/HeFS.cc +++ b/dev/kernel/src/FS/HeFS.cc @@ -737,7 +737,7 @@ namespace Detail { auto old_start = start; hefsi_traverse_tree(dir, root, start); - + if (start == 0 || start == old_start) break; } @@ -824,7 +824,7 @@ _Output Bool HeFileSystemParser::Format(_Input _Output DriveTrait* drive, _Input root->fSectorSize = drive->fSectorSz; - root->fStartIND = drive->fLbaStart + sizeof(HEFS_BOOT_NODE) + sizeof(HEFS_BOOT_NODE); + root->fStartIND = drive->fLbaStart + sizeof(HEFS_BOOT_NODE); root->fEndIND = drive->fLbaEnd; root->fINDCount = 0; @@ -870,7 +870,7 @@ _Output Bool HeFileSystemParser::Format(_Input _Output DriveTrait* drive, _Input /// @note this allocates 4 ind at format. SizeT cnt = 4UL; - Lba next = drive->fLbaStart + sizeof(HEFS_BOOT_NODE) + sizeof(HEFS_BOOT_NODE); + Lba next = root->fStartIND + sizeof(HEFS_BOOT_NODE); HEFS_INDEX_NODE_DIRECTORY* index_node = new HEFS_INDEX_NODE_DIRECTORY(); @@ -889,11 +889,11 @@ _Output Bool HeFileSystemParser::Format(_Input _Output DriveTrait* drive, _Input index_node->fChecksum = 0; index_node->fIndexNodeChecksum = 0; - index_node->fUID = 0; - index_node->fGID = 0; - index_node->fMode = 0; + index_node->fUID = 0; + index_node->fGID = 0; + index_node->fMode = 0; - index_node->fColor = kHeFSBlack; + index_node->fColor = kHeFSBlack; index_node->fChild = 0; index_node->fParent = 0; index_node->fNext = 0; diff --git a/dev/kernel/src/Utils.cc b/dev/kernel/src/Utils.cc index eed6f076..ea0ff7a7 100644 --- a/dev/kernel/src/Utils.cc +++ b/dev/kernel/src/Utils.cc @@ -179,6 +179,8 @@ Char* rt_string_has_char(Char* str, Char chr) { } } // namespace Kernel +////// @note These symbols were written to satisfy gcc, clang and other compiler complaints. + EXTERN_C void* memset(void* dst, int c, long long unsigned int len) { return Kernel::rt_set_memory(dst, c, len); } @@ -187,3 +189,8 @@ EXTERN_C void* memcpy(void* dst, const void* src, long long unsigned int len) { Kernel::rt_copy_memory(const_cast(src), dst, len); return dst; } + +EXTERN_C Kernel::Int32 strcmp(const char* dst, const char* src) { + return Kernel::rt_string_cmp(dst, src, Kernel::rt_string_len(dst)); +} + -- cgit v1.2.3