diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-23 18:20:04 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-23 18:20:04 +0200 |
| commit | bac8c9a8306e1582ef24ba68a412a29674c97775 (patch) | |
| tree | 956155581fdb44fb6c82673a5f71a00cc6f4c89c /dev/ZKA | |
| parent | 73e0c81b5c8325db7aaec773fcc657f3ef50b0b8 (diff) | |
[IMP/WIP] AHCI disk driver for kernel DLL.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA')
41 files changed, 150 insertions, 87 deletions
diff --git a/dev/ZKA/ArchKit/ArchKit.hxx b/dev/ZKA/ArchKit/ArchKit.hxx index bcaaf5f7..51df2905 100644 --- a/dev/ZKA/ArchKit/ArchKit.hxx +++ b/dev/ZKA/ArchKit/ArchKit.hxx @@ -16,9 +16,9 @@ #include <HALKit/AMD64/HalPageAlloc.hxx> #include <HALKit/AMD64/Hypervisor.hxx> #include <HALKit/AMD64/Processor.hxx> -#elif defined(__NEWOS_POWER64__) +#elif defined(__ZKA_POWER64__) #include <HALKit/POWER/Processor.hxx> -#elif defined(__NEWOS_ARM64__) +#elif defined(__ZKA_ARM64__) #include <HALKit/ARM64/Processor.hxx> #else #error !!! unknown architecture !!! diff --git a/dev/ZKA/CompilerKit/Detail.hxx b/dev/ZKA/CompilerKit/Detail.hxx index 4cc25dae..fd9cf7a3 100644 --- a/dev/ZKA/CompilerKit/Detail.hxx +++ b/dev/ZKA/CompilerKit/Detail.hxx @@ -10,18 +10,18 @@ #include <NewKit/Defines.hxx> #endif // ifdef __NEWOSKRNL__ -#define NEWOS_COPY_DELETE(KLASS) \ +#define ZKA_COPY_DELETE(KLASS) \ KLASS& operator=(const KLASS&) = delete; \ KLASS(const KLASS&) = delete; -#define NEWOS_COPY_DEFAULT(KLASS) \ +#define ZKA_COPY_DEFAULT(KLASS) \ KLASS& operator=(const KLASS&) = default; \ KLASS(const KLASS&) = default; -#define NEWOS_MOVE_DELETE(KLASS) \ +#define ZKA_MOVE_DELETE(KLASS) \ KLASS& operator=(KLASS&&) = delete; \ KLASS(KLASS&&) = delete; -#define NEWOS_MOVE_DEFAULT(KLASS) \ +#define ZKA_MOVE_DEFAULT(KLASS) \ KLASS& operator=(KLASS&&) = default; \ KLASS(KLASS&&) = default; diff --git a/dev/ZKA/FSKit/IndexableProperty.hxx b/dev/ZKA/FSKit/IndexableProperty.hxx index 89d90ddc..652e0e74 100644 --- a/dev/ZKA/FSKit/IndexableProperty.hxx +++ b/dev/ZKA/FSKit/IndexableProperty.hxx @@ -38,7 +38,7 @@ namespace Kernel ~IndexableProperty() override = default; - NEWOS_COPY_DEFAULT(IndexableProperty); + ZKA_COPY_DEFAULT(IndexableProperty); public: IndexProperty& Leak() noexcept; diff --git a/dev/ZKA/FSKit/NewFS.hxx b/dev/ZKA/FSKit/NewFS.hxx index d243c6bc..53e1470e 100644 --- a/dev/ZKA/FSKit/NewFS.hxx +++ b/dev/ZKA/FSKit/NewFS.hxx @@ -226,7 +226,7 @@ namespace Kernel ~NewFSParser() = default; public: - NEWOS_COPY_DEFAULT(NewFSParser); + ZKA_COPY_DEFAULT(NewFSParser); public: /// @brief Creates a new fork inside the New filesystem partition. diff --git a/dev/ZKA/FirmwareKit/EPM.hxx b/dev/ZKA/FirmwareKit/EPM.hxx index ee1d1c56..d9f7adf5 100644 --- a/dev/ZKA/FirmwareKit/EPM.hxx +++ b/dev/ZKA/FirmwareKit/EPM.hxx @@ -52,7 +52,7 @@ #ifdef __ZKA_AMD64__ #define kEPMMagic kEPMMagic86 #else -#ifdef __NEWOS_ARM64__ +#ifdef __ZKA_ARM64__ #define kEPMMagic kEPMMagicARM #else #define kEPMMagic kEPMMagicError diff --git a/dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx b/dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx index 27706784..87dd1d24 100644 --- a/dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx +++ b/dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx @@ -11,7 +11,7 @@ #ifdef __ZKA_AMD64__ #include <HALKit/AMD64/HalPageAlloc.hxx> -#elif defined(__NEWOS_ARM64__) +#elif defined(__ZKA_ARM64__) #include <HALKit/ARM64/HalPageAlloc.hxx> #endif diff --git a/dev/ZKA/HALKit/AMD64/PCI/Device.cxx b/dev/ZKA/HALKit/AMD64/PCI/Device.cxx index 214a640a..bc6ba2bb 100644 --- a/dev/ZKA/HALKit/AMD64/PCI/Device.cxx +++ b/dev/ZKA/HALKit/AMD64/PCI/Device.cxx @@ -7,7 +7,7 @@ #include <ArchKit/ArchKit.hxx> #include <KernelKit/PCI/Device.hxx> -Kernel::UInt NewOSPCIReadRaw(Kernel::UInt bar, Kernel::UShort bus, Kernel::UShort dev, Kernel::UShort fun) +Kernel::UInt ZKA_PCIReadRaw(Kernel::UInt bar, Kernel::UShort bus, Kernel::UShort dev, Kernel::UShort fun) { Kernel::UInt target = 0x80000000 | ((Kernel::UInt)bus << 16) | ((Kernel::UInt)dev << 11) | ((Kernel::UInt)fun << 8) | @@ -19,7 +19,7 @@ Kernel::UInt NewOSPCIReadRaw(Kernel::UInt bar, Kernel::UShort bus, Kernel::UShor return Kernel::HAL::In32((Kernel::UShort)Kernel::PCI::PciConfigKind::ConfigData); } -void NewOSPCISetCfgTarget(Kernel::UInt bar, Kernel::UShort bus, Kernel::UShort dev, Kernel::UShort fun) +void ZKA_PCISetCfgTarget(Kernel::UInt bar, Kernel::UShort bus, Kernel::UShort dev, Kernel::UShort fun) { Kernel::UInt target = 0x80000000 | ((Kernel::UInt)bus << 16) | ((Kernel::UInt)dev << 11) | ((Kernel::UInt)fun << 8) | @@ -29,34 +29,40 @@ void NewOSPCISetCfgTarget(Kernel::UInt bar, Kernel::UShort bus, Kernel::UShort d target); } +#define PCI_BAR_IO 0x01 +#define PCI_BAR_LOWMEM 0x02 +#define PCI_BAR_64 0x04 +#define PCI_BAR_PREFETCH 0x08 + namespace Kernel::PCI { - Device::Device(UShort bus, UShort device, UShort func, UShort bar) + Device::Device(UShort bus, UShort device, UShort func, UInt32 bar) : fBus(bus), fDevice(device), fFunction(func), fBar(bar) { + // get bar 0 + auto bar_zero = 0x10 + bar * sizeof(UInt32); + fBar = this->Read(bar_zero, 4); } - Device::~Device() - { - } + Device::~Device() = default; UInt Device::Read(UInt bar, Size sz) { - NewOSPCISetCfgTarget(bar, fBus, fDevice, fFunction); + ZKA_PCISetCfgTarget(bar, fBus, fDevice, fFunction); if (sz == 4) - return HAL::In32((UShort)PciConfigKind::ConfigData + (fBar & 3)); + return HAL::In32((UShort)PciConfigKind::ConfigData + (bar & 3)); if (sz == 2) - return HAL::In16((UShort)PciConfigKind::ConfigData + (fBar & 3)); + return HAL::In16((UShort)PciConfigKind::ConfigData + (bar & 3)); if (sz == 1) - return HAL::In8((UShort)PciConfigKind::ConfigData + (fBar & 3)); + return HAL::In8((UShort)PciConfigKind::ConfigData + (bar & 3)); return 0xFFFF; } void Device::Write(UInt bar, UIntPtr data, Size sz) { - NewOSPCISetCfgTarget(bar, fBus, fDevice, fFunction); + ZKA_PCISetCfgTarget(bar, fBus, fDevice, fFunction); if (sz == 4) HAL::Out32((UShort)PciConfigKind::ConfigData + (fBar & 3), (UInt)data); @@ -68,37 +74,37 @@ namespace Kernel::PCI UShort Device::DeviceId() { - return (UShort)(NewOSPCIReadRaw(0x0 >> 16, fBus, fDevice, fFunction)); + return (UShort)(ZKA_PCIReadRaw(0x0 >> 16, fBus, fDevice, fFunction)); } UShort Device::VendorId() { - return (UShort)(NewOSPCIReadRaw(0x0, fBus, fDevice, fFunction) >> 16); + return (UShort)(ZKA_PCIReadRaw(0x0, fBus, fDevice, fFunction) >> 16); } UShort Device::InterfaceId() { - return (UShort)(NewOSPCIReadRaw(0x0, fBus, fDevice, fFunction) >> 16); + return (UShort)(ZKA_PCIReadRaw(0x0, fBus, fDevice, fFunction) >> 16); } UChar Device::Class() { - return (UChar)(NewOSPCIReadRaw(0x08, fBus, fDevice, fFunction) >> 24); + return (UChar)(ZKA_PCIReadRaw(0x08, fBus, fDevice, fFunction) >> 24); } UChar Device::Subclass() { - return (UChar)(NewOSPCIReadRaw(0x08, fBus, fDevice, fFunction) >> 16); + return (UChar)(ZKA_PCIReadRaw(0x08, fBus, fDevice, fFunction) >> 16); } UChar Device::ProgIf() { - return (UChar)(NewOSPCIReadRaw(0x08, fBus, fDevice, fFunction) >> 8); + return (UChar)(ZKA_PCIReadRaw(0x08, fBus, fDevice, fFunction) >> 8); } UChar Device::HeaderType() { - return (UChar)(NewOSPCIReadRaw(0xC, fBus, fDevice, fFunction) >> 16); + return (UChar)(ZKA_PCIReadRaw(0xC, fBus, fDevice, fFunction) >> 16); } void Device::EnableMmio() @@ -113,6 +119,11 @@ namespace Kernel::PCI Write(0x04, enable, sizeof(UShort)); } + UInt32 Device::Bar() + { + return fBar; + } + UShort Device::Vendor() { UShort vendor = VendorId(); diff --git a/dev/ZKA/HALKit/AMD64/PCI/Iterator.cxx b/dev/ZKA/HALKit/AMD64/PCI/Iterator.cxx index 47b16462..20a94115 100644 --- a/dev/ZKA/HALKit/AMD64/PCI/Iterator.cxx +++ b/dev/ZKA/HALKit/AMD64/PCI/Iterator.cxx @@ -15,13 +15,13 @@ namespace Kernel::PCI Iterator::Iterator(const Types::PciDeviceKind& type) { // probe devices. - for (int bus = 0; bus < NEWOS_BUS_COUNT; ++bus) + for (int bus = 0; bus < ZKA_BUS_COUNT; ++bus) { - for (int device = 0; device < NEWOS_DEVICE_COUNT; ++device) + for (int device = 0; device < ZKA_DEVICE_COUNT; ++device) { - for (int function = 0; function < NEWOS_FUNCTION_COUNT; ++function) + for (int function = 0; function < ZKA_FUNCTION_COUNT; ++function) { - Device dev(bus, device, function, 0); + Device dev(bus, device, function, type == Types::PciDeviceKind::MassStorageController ? 5 : 1); if (dev.Class() == (UChar)type) { diff --git a/dev/ZKA/HALKit/AMD64/Processor.hxx b/dev/ZKA/HALKit/AMD64/Processor.hxx index b6ae0ab3..d1bda9ef 100644 --- a/dev/ZKA/HALKit/AMD64/Processor.hxx +++ b/dev/ZKA/HALKit/AMD64/Processor.hxx @@ -317,7 +317,7 @@ namespace Kernel::HAL ~APICController() = default; - NEWOS_COPY_DEFAULT(APICController); + ZKA_COPY_DEFAULT(APICController); public: UInt32 Read(UInt32 reg) noexcept; diff --git a/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx b/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx index 0974c240..e8742cdc 100644 --- a/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx +++ b/dev/ZKA/HALKit/AMD64/Storage/AHCI.cxx @@ -26,6 +26,7 @@ enum }; static Kernel::PCI::Device kAhciDevice; +static HbaPort* kAhciPort = nullptr; /// @brief Initializes an AHCI disk. /// @param PortsImplemented the amount of port that have been detected. @@ -35,7 +36,8 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented) using namespace Kernel; PCI::Iterator iterator(Types::PciDeviceKind::MassStorageController); - for (SizeT devIndex = 0; devIndex < NEWOS_BUS_COUNT; ++devIndex) + + for (SizeT devIndex = 0; devIndex < ZKA_BUS_COUNT; ++devIndex) { if (iterator[devIndex].Leak().Subclass() == kSATASubClass && iterator[devIndex].Leak().ProgIf() == kSATAProgIfAHCI) @@ -43,6 +45,33 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented) iterator[devIndex].Leak().EnableMmio(); /// enable the memory i/o for this ahci device. kAhciDevice = iterator[devIndex].Leak(); /// and then leak the reference. + HbaMem* mem_ahci = (HbaMem*)kAhciDevice.Bar(); + + UInt32 pi = mem_ahci->Pi; + Int32 i = 0; + + const auto cMaxAhciDevices = 32; + const auto cAhciSig = 0x00000101; + const auto cAhciPresent = 0x03; + + while (i < cMaxAhciDevices) + { + if (pi & 1 && + (mem_ahci->Ports[i].Ssts & 0x0F) == cAhciPresent && + ((mem_ahci->Ports[i].Ssts >> 8) & 0x0F) == 1) + { + kcout << "newoskrnl: Port is implemented.\r"; + + if (mem_ahci->Ports[i].Sig == cAhciSig) + { + kcout << "newoskrnl: device is SATA.\r"; + } + } + + pi >>= 1; + i++; + } + kcout << "newoskrnl: [PCI] Found AHCI controller.\r"; return true; @@ -64,4 +93,17 @@ Kernel::Void drv_std_read(Kernel::UInt64 Lba, Kernel::Char* Buf, Kernel::SizeT S Kernel::Void drv_std_write(Kernel::UInt64 Lba, Kernel::Char* Buf, Kernel::SizeT SectorSz, Kernel::SizeT Size) { } +/*** + @brief Getter, gets the number of sectors inside the drive. +*/ +Kernel::SizeT drv_std_get_sector_count() +{ + return 0; +} + +/// @brief Get the drive size. +Kernel::SizeT drv_std_get_drv_size() +{ + return 0; +} #endif // __AHCI__ diff --git a/dev/ZKA/HALKit/POWER/HalHart.cxx b/dev/ZKA/HALKit/POWER/HalHart.cxx index 8327b8e0..ce27ddad 100644 --- a/dev/ZKA/HALKit/POWER/HalHart.cxx +++ b/dev/ZKA/HALKit/POWER/HalHart.cxx @@ -14,12 +14,12 @@ using namespace Kernel; /// wakes up thread from hang. void mp_wakeup_thread(HAL::StackFramePtr stack) { - NEWOS_UNUSED(stack); + ZKA_UNUSED(stack); } /// @brief makes thread sleep. /// hooks and hangs thread to prevent code from executing. void mp_hang_thread(HAL::StackFramePtr stack) { - NEWOS_UNUSED(stack); + ZKA_UNUSED(stack); } diff --git a/dev/ZKA/KernelKit/DebugOutput.hxx b/dev/ZKA/KernelKit/DebugOutput.hxx index b8fd97dd..fcf18bff 100644 --- a/dev/ZKA/KernelKit/DebugOutput.hxx +++ b/dev/ZKA/KernelKit/DebugOutput.hxx @@ -51,7 +51,7 @@ namespace Kernel return ("TerminalDevice"); } - NEWOS_COPY_DEFAULT(TerminalDevice); + ZKA_COPY_DEFAULT(TerminalDevice); STATIC TerminalDevice The() noexcept; }; diff --git a/dev/ZKA/KernelKit/DriveManager.hxx b/dev/ZKA/KernelKit/DriveManager.hxx index 6485f995..6df3d3b0 100644 --- a/dev/ZKA/KernelKit/DriveManager.hxx +++ b/dev/ZKA/KernelKit/DriveManager.hxx @@ -78,7 +78,7 @@ namespace Kernel explicit MountpointInterface() = default; ~MountpointInterface() = default; - NEWOS_COPY_DEFAULT(MountpointInterface); + ZKA_COPY_DEFAULT(MountpointInterface); public: DriveTrait& A() diff --git a/dev/ZKA/KernelKit/FileManager.hxx b/dev/ZKA/KernelKit/FileManager.hxx index 3ac3fe3b..af33208a 100644 --- a/dev/ZKA/KernelKit/FileManager.hxx +++ b/dev/ZKA/KernelKit/FileManager.hxx @@ -78,7 +78,7 @@ namespace Kernel virtual ~FilesystemManagerInterface() = default; public: - NEWOS_COPY_DEFAULT(FilesystemManagerInterface); + ZKA_COPY_DEFAULT(FilesystemManagerInterface); public: /// @brief Mounts a new filesystem into an active state. @@ -143,7 +143,7 @@ namespace Kernel ~NewFilesystemManager() override; public: - NEWOS_COPY_DEFAULT(NewFilesystemManager); + ZKA_COPY_DEFAULT(NewFilesystemManager); public: NodePtr Create(const Char* path) override; diff --git a/dev/ZKA/KernelKit/LoaderInterface.hxx b/dev/ZKA/KernelKit/LoaderInterface.hxx index ceb7d528..816b6897 100644 --- a/dev/ZKA/KernelKit/LoaderInterface.hxx +++ b/dev/ZKA/KernelKit/LoaderInterface.hxx @@ -21,7 +21,7 @@ namespace Kernel explicit LoaderInterface() = default; virtual ~LoaderInterface() = default; - NEWOS_COPY_DEFAULT(LoaderInterface); + ZKA_COPY_DEFAULT(LoaderInterface); public: virtual _Output const Char* AsString() = 0; diff --git a/dev/ZKA/KernelKit/MP.hxx b/dev/ZKA/KernelKit/MP.hxx index bc94102e..0194e8dd 100644 --- a/dev/ZKA/KernelKit/MP.hxx +++ b/dev/ZKA/KernelKit/MP.hxx @@ -49,7 +49,7 @@ namespace Kernel ~HardwareThread(); public: - NEWOS_COPY_DEFAULT(HardwareThread) + ZKA_COPY_DEFAULT(HardwareThread) public: operator bool(); @@ -92,7 +92,7 @@ namespace Kernel public: ~HardwareThreadScheduler(); - NEWOS_COPY_DEFAULT(HardwareThreadScheduler); + ZKA_COPY_DEFAULT(HardwareThreadScheduler); public: bool Switch(HAL::StackFramePtr the); diff --git a/dev/ZKA/KernelKit/PCI/Device.hxx b/dev/ZKA/KernelKit/PCI/Device.hxx index a562219a..b1c011e9 100644 --- a/dev/ZKA/KernelKit/PCI/Device.hxx +++ b/dev/ZKA/KernelKit/PCI/Device.hxx @@ -22,7 +22,7 @@ namespace Kernel::PCI Device() = default; public: - explicit Device(UShort bus, UShort device, UShort function, UShort bar); + explicit Device(UShort bus, UShort device, UShort function, UInt32 bar); Device& operator=(const Device&) = default; @@ -60,6 +60,7 @@ namespace Kernel::PCI UChar Subclass(); UChar ProgIf(); UChar HeaderType(); + UInt32 Bar(); public: void EnableMmio(); @@ -71,7 +72,7 @@ namespace Kernel::PCI UShort fBus; UShort fDevice; UShort fFunction; - UShort fBar; + UInt32 fBar; }; } // namespace Kernel::PCI diff --git a/dev/ZKA/KernelKit/PCI/Iterator.hxx b/dev/ZKA/KernelKit/PCI/Iterator.hxx index 5f2ca089..cad8f09f 100644 --- a/dev/ZKA/KernelKit/PCI/Iterator.hxx +++ b/dev/ZKA/KernelKit/PCI/Iterator.hxx @@ -13,9 +13,9 @@ #include <NewKit/Defines.hxx> #include <NewKit/Ref.hxx> -#define NEWOS_BUS_COUNT (256) -#define NEWOS_DEVICE_COUNT (33) -#define NEWOS_FUNCTION_COUNT (8) +#define ZKA_BUS_COUNT (256) +#define ZKA_DEVICE_COUNT (33) +#define ZKA_FUNCTION_COUNT (8) namespace Kernel::PCI { @@ -36,7 +36,7 @@ namespace Kernel::PCI Ref<PCI::Device> operator[](const Size& sz); private: - Array<PCI::Device, NEWOS_BUS_COUNT> fDevices; + Array<PCI::Device, ZKA_BUS_COUNT> fDevices; }; } // namespace Kernel::PCI diff --git a/dev/ZKA/KernelKit/PEFCodeManager.hxx b/dev/ZKA/KernelKit/PEFCodeManager.hxx index db01d23c..2935f709 100644 --- a/dev/ZKA/KernelKit/PEFCodeManager.hxx +++ b/dev/ZKA/KernelKit/PEFCodeManager.hxx @@ -31,7 +31,7 @@ namespace Kernel ~PEFLoader() override; public: - NEWOS_COPY_DEFAULT(PEFLoader); + ZKA_COPY_DEFAULT(PEFLoader); public: const Char* Path() override; diff --git a/dev/ZKA/KernelKit/PEFSharedObject.hxx b/dev/ZKA/KernelKit/PEFSharedObject.hxx index 690f0b5d..48b70508 100644 --- a/dev/ZKA/KernelKit/PEFSharedObject.hxx +++ b/dev/ZKA/KernelKit/PEFSharedObject.hxx @@ -40,7 +40,7 @@ namespace Kernel ~PEFSharedObjectInterface() = default; public: - NEWOS_COPY_DEFAULT(PEFSharedObjectInterface); + ZKA_COPY_DEFAULT(PEFSharedObjectInterface); private: PEF_SHARED_OBJECT_TRAITS* fMounted{nullptr}; diff --git a/dev/ZKA/KernelKit/ProcessScheduler.hxx b/dev/ZKA/KernelKit/ProcessScheduler.hxx index c74dee6a..810886ab 100644 --- a/dev/ZKA/KernelKit/ProcessScheduler.hxx +++ b/dev/ZKA/KernelKit/ProcessScheduler.hxx @@ -136,7 +136,7 @@ namespace Kernel ~PROCESS_HEADER_BLOCK() = default; - NEWOS_COPY_DEFAULT(PROCESS_HEADER_BLOCK) + ZKA_COPY_DEFAULT(PROCESS_HEADER_BLOCK) public: void SetEntrypoint(UIntPtr& imageStart) noexcept; @@ -229,7 +229,7 @@ namespace Kernel explicit ProcessTeam() = default; ~ProcessTeam() = default; - NEWOS_COPY_DEFAULT(ProcessTeam); + ZKA_COPY_DEFAULT(ProcessTeam); MutableArray<Ref<PROCESS_HEADER_BLOCK>>& AsArray(); Ref<PROCESS_HEADER_BLOCK>& AsRef(); @@ -252,7 +252,7 @@ namespace Kernel public: ~ProcessScheduler() = default; - NEWOS_COPY_DEFAULT(ProcessScheduler) + ZKA_COPY_DEFAULT(ProcessScheduler) operator bool(); bool operator!(); diff --git a/dev/ZKA/KernelKit/Semaphore.hxx b/dev/ZKA/KernelKit/Semaphore.hxx index efef472a..7f6b2001 100644 --- a/dev/ZKA/KernelKit/Semaphore.hxx +++ b/dev/ZKA/KernelKit/Semaphore.hxx @@ -35,7 +35,7 @@ namespace Kernel bool LockOrWait(PROCESS_HEADER_BLOCK* process, TimerInterface* timer); public: - NEWOS_COPY_DEFAULT(Semaphore); + ZKA_COPY_DEFAULT(Semaphore); private: ProcessHeaderRef fLockingProcess{nullptr}; diff --git a/dev/ZKA/KernelKit/Timer.hxx b/dev/ZKA/KernelKit/Timer.hxx index 603cacff..e6afd454 100644 --- a/dev/ZKA/KernelKit/Timer.hxx +++ b/dev/ZKA/KernelKit/Timer.hxx @@ -23,7 +23,7 @@ namespace Kernel virtual ~TimerInterface() = default; public: - NEWOS_COPY_DEFAULT(TimerInterface); + ZKA_COPY_DEFAULT(TimerInterface); public: virtual Int32 Wait() noexcept; @@ -36,7 +36,7 @@ namespace Kernel ~SoftwareTimer() override; public: - NEWOS_COPY_DEFAULT(SoftwareTimer); + ZKA_COPY_DEFAULT(SoftwareTimer); public: Int32 Wait() noexcept override; @@ -53,7 +53,7 @@ namespace Kernel ~HardwareTimer() override; public: - NEWOS_COPY_DEFAULT(HardwareTimer); + ZKA_COPY_DEFAULT(HardwareTimer); public: Int32 Wait() noexcept override; diff --git a/dev/ZKA/KernelKit/User.hxx b/dev/ZKA/KernelKit/User.hxx index 0aec93ad..ddc422c3 100644 --- a/dev/ZKA/KernelKit/User.hxx +++ b/dev/ZKA/KernelKit/User.hxx @@ -49,7 +49,7 @@ namespace Kernel ~User(); public: - NEWOS_COPY_DEFAULT(User) + ZKA_COPY_DEFAULT(User) public: bool operator==(const User& lhs); @@ -90,7 +90,7 @@ namespace Kernel User* fRootUser{nullptr}; public: - NEWOS_COPY_DELETE(UserManager); + ZKA_COPY_DELETE(UserManager); STATIC UserManager* The() noexcept; Bool TryLogIn(User& user, const Char* password, const Char* right_password) noexcept; diff --git a/dev/ZKA/Modules/AHCI/AHCI.hxx b/dev/ZKA/Modules/AHCI/AHCI.hxx index 6e6e5dba..7d8c7cd5 100644 --- a/dev/ZKA/Modules/AHCI/AHCI.hxx +++ b/dev/ZKA/Modules/AHCI/AHCI.hxx @@ -18,6 +18,8 @@ // Forward declarations of structs. +#define kAHCISectorSize (512U) + struct HbaPort; struct FisData; struct FisRegD2H; @@ -262,7 +264,7 @@ typedef struct HbaMem final Kernel::UInt16 Resv0; Kernel::UInt32 Resv2; - HbaPort Ports[1]; // 1 ~ 32 + HbaPort Ports[32]; // 1 ~ 32, 32 is the max ahci devices per controller. } HbaMem; typedef struct HbaCmdHeader final diff --git a/dev/ZKA/Modules/CoreCG/Accessibility.hxx b/dev/ZKA/Modules/CoreCG/Accessibility.hxx index 743b81ee..3ba942dc 100644 --- a/dev/ZKA/Modules/CoreCG/Accessibility.hxx +++ b/dev/ZKA/Modules/CoreCG/Accessibility.hxx @@ -26,7 +26,7 @@ namespace Kernel explicit UIAccessibilty() = default; public: - NEWOS_COPY_DELETE(UIAccessibilty); + ZKA_COPY_DELETE(UIAccessibilty); static UIAccessibilty& The() { diff --git a/dev/ZKA/Modules/PS2/PS2MouseInterface.hxx b/dev/ZKA/Modules/PS2/PS2MouseInterface.hxx index 0a0f4aa8..1cba256e 100644 --- a/dev/ZKA/Modules/PS2/PS2MouseInterface.hxx +++ b/dev/ZKA/Modules/PS2/PS2MouseInterface.hxx @@ -26,7 +26,7 @@ namespace Kernel explicit PS2MouseInterface() = default; ~PS2MouseInterface() = default; - NEWOS_COPY_DEFAULT(PS2MouseInterface); + ZKA_COPY_DEFAULT(PS2MouseInterface); public: /// @brief Enables PS2 mouse for kernel. diff --git a/dev/ZKA/NewKit/Json.hxx b/dev/ZKA/NewKit/Json.hxx index 74566942..723a9497 100644 --- a/dev/ZKA/NewKit/Json.hxx +++ b/dev/ZKA/NewKit/Json.hxx @@ -42,7 +42,7 @@ namespace Kernel ~JsonType() = default; - NEWOS_COPY_DEFAULT(JsonType); + ZKA_COPY_DEFAULT(JsonType); const Bool& IsUndefined() { return fUndefined; } diff --git a/dev/ZKA/NewKit/Macros.hxx b/dev/ZKA/NewKit/Macros.hxx index a17d91fb..b8f316bf 100644 --- a/dev/ZKA/NewKit/Macros.hxx +++ b/dev/ZKA/NewKit/Macros.hxx @@ -107,7 +107,7 @@ #define CONST const #define STRINGIFY(X) #X -#define NEWOS_UNUSED(X) ((Kernel::Void)X) +#define ZKA_UNUSED(X) ((Kernel::Void)X) #ifndef RGB #define RGB(R, G, B) (Kernel::UInt32)(R | G << 0x8 | B << 0x10) diff --git a/dev/ZKA/NewKit/MutableArray.hxx b/dev/ZKA/NewKit/MutableArray.hxx index 0015f9a9..1f9a63c0 100644 --- a/dev/ZKA/NewKit/MutableArray.hxx +++ b/dev/ZKA/NewKit/MutableArray.hxx @@ -164,7 +164,7 @@ namespace Kernel explicit MutableArray() = default; virtual ~MutableArray() = default; - NEWOS_COPY_DEFAULT(MutableArray) + ZKA_COPY_DEFAULT(MutableArray) public: Boolean Add(const T val) diff --git a/dev/ZKA/Sources/CxxAbi-ARM64.cxx b/dev/ZKA/Sources/CxxAbi-ARM64.cxx index b0cb7354..798cecab 100644 --- a/dev/ZKA/Sources/CxxAbi-ARM64.cxx +++ b/dev/ZKA/Sources/CxxAbi-ARM64.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#ifdef __NEWOS_ARM64__ +#ifdef __ZKA_ARM64__ #include <KernelKit/DebugOutput.hxx> #include <NewKit/CxxAbi.hxx> @@ -71,4 +71,4 @@ EXTERN_C void _purecall() Kernel::kcout << "newoskrnl: C++ placeholder method.\n"; } -#endif // ifdef __NEWOS_ARM64__ +#endif // ifdef __ZKA_ARM64__ diff --git a/dev/ZKA/Sources/DriveManager.cxx b/dev/ZKA/Sources/DriveManager.cxx index b26c2c16..c4cebc3f 100644 --- a/dev/ZKA/Sources/DriveManager.cxx +++ b/dev/ZKA/Sources/DriveManager.cxx @@ -46,7 +46,7 @@ namespace Kernel } #ifdef __AHCI__ - drv_std_write(pckt->fLba, (Char*)pckt->fPacketContent, kATASectorSize, pckt->fPacketSize); + drv_std_write(pckt->fLba, (Char*)pckt->fPacketContent, kAHCISectorSize, pckt->fPacketSize); #elif defined(__ATA_PIO__) || defined(__ATA_DMA__) drv_std_write(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, kATASectorSize, pckt->fPacketSize); #endif @@ -69,6 +69,9 @@ namespace Kernel kATAIO = ATA_PRIMARY_IO; MUST_PASS(drv_std_init(kATAIO, kATAMaster, kATAIO, kATAMaster)); +#elif defined(__AHCI__) + UInt16 pi = 0; + MUST_PASS(drv_std_init(pi)); #endif // if defined(__ATA_PIO__) || defined (__ATA_DMA__) pckt->fPacketGood = true; @@ -111,7 +114,7 @@ namespace Kernel { DriveTrait trait; - rt_copy_memory((VoidPtr) "/Mount/Null", trait.fName, rt_string_len("/Mount/Null")); + rt_copy_memory((VoidPtr) "\\NUL", trait.fName, rt_string_len("\\NUL")); trait.fKind = kInvalidDrive; trait.fInput = io_drv_unimplemented; diff --git a/dev/ZKA/Sources/FileManager.cxx b/dev/ZKA/Sources/FileManager.cxx index 92245f4f..0912da27 100644 --- a/dev/ZKA/Sources/FileManager.cxx +++ b/dev/ZKA/Sources/FileManager.cxx @@ -119,7 +119,7 @@ namespace Kernel if (!data) return; - NEWOS_UNUSED(flags); + ZKA_UNUSED(flags); if ((reinterpret_cast<NFS_CATALOG_STRUCT*>(node))->Kind == kNewFSCatalogKindFile) fImpl->WriteCatalog(reinterpret_cast<NFS_CATALOG_STRUCT*>(node), (flags & cFileFlagRsrc ? true : false), data, size, @@ -137,7 +137,7 @@ namespace Kernel if (!sz) return nullptr; - NEWOS_UNUSED(flags); + ZKA_UNUSED(flags); if ((reinterpret_cast<NFS_CATALOG_STRUCT*>(node))->Kind == kNewFSCatalogKindFile) return fImpl->ReadCatalog(reinterpret_cast<NFS_CATALOG_STRUCT*>(node), (flags & cFileFlagRsrc ? true : false), sz, diff --git a/dev/ZKA/Sources/New+Delete.cxx b/dev/ZKA/Sources/New+Delete.cxx index 12ea38a7..b1a3b611 100644 --- a/dev/ZKA/Sources/New+Delete.cxx +++ b/dev/ZKA/Sources/New+Delete.cxx @@ -44,7 +44,7 @@ void operator delete(void* ptr, size_t sz) if (ptr == nullptr) return; - NEWOS_UNUSED(sz); + ZKA_UNUSED(sz); Kernel::mm_delete_ke_heap(ptr); } diff --git a/dev/ZKA/Sources/PEFCodeManager.cxx b/dev/ZKA/Sources/PEFCodeManager.cxx index 4a729992..f2f1e815 100644 --- a/dev/ZKA/Sources/PEFCodeManager.cxx +++ b/dev/ZKA/Sources/PEFCodeManager.cxx @@ -20,15 +20,15 @@ namespace Kernel /// @brief Get the PEF platform signature according to the compiled backebnd UInt32 rt_get_pef_platform(void) noexcept { -#ifdef __NEWOS_32X0__ +#ifdef __ZKA_32X0__ return kPefArch32x0; -#elif defined(__NEWOS_64X0__) +#elif defined(__ZKA_64X0__) return kPefArch64x0; #elif defined(__ZKA_AMD64__) return kPefArchAMD64; -#elif defined(__NEWOS_PPC64__) +#elif defined(__ZKA_PPC64__) return kPefArchPowerPC; -#elif defined(__NEWOS_ARM64__) +#elif defined(__ZKA_ARM64__) return kPefArchARM64; #else return kPefArchInvalid; diff --git a/dev/ZKA/Sources/PageAllocator.cxx b/dev/ZKA/Sources/PageAllocator.cxx index 4f64b05f..4a07a12d 100644 --- a/dev/ZKA/Sources/PageAllocator.cxx +++ b/dev/ZKA/Sources/PageAllocator.cxx @@ -26,14 +26,14 @@ namespace Kernel::Detail void exec_disable(UIntPtr VirtualAddr) { -#ifdef __NEWOS_SUPPORT_NX__ +#ifdef __ZKA_SUPPORT_NX__ PTE* VirtualAddrTable = reinterpret_cast<PTE*>(VirtualAddr); MUST_PASS(!VirtualAddrTable->ExecDisable == false); VirtualAddrTable->ExecDisable = true; hal_flush_tlb(); -#endif // ifdef __NEWOS_SUPPORT_NX__ +#endif // ifdef __ZKA_SUPPORT_NX__ } bool page_disable(UIntPtr VirtualAddr) diff --git a/dev/ZKA/Sources/PageManager.cxx b/dev/ZKA/Sources/PageManager.cxx index 77dbfd32..549415f3 100644 --- a/dev/ZKA/Sources/PageManager.cxx +++ b/dev/ZKA/Sources/PageManager.cxx @@ -9,9 +9,9 @@ #ifdef __ZKA_AMD64__ #include <HALKit/AMD64/HalPageAlloc.hxx> -#elif defined(__NEWOS_ARM64__) +#elif defined(__ZKA_ARM64__) #include <HALKit/ARM64/HalPageAlloc.hxx> -#endif // ifdef __ZKA_AMD64__ || defined(__NEWOS_ARM64__) +#endif // ifdef __ZKA_AMD64__ || defined(__ZKA_ARM64__) //! null deref will throw (Page Zero detected, aborting app!) #define kProtectedRegionEnd (512) diff --git a/dev/ZKA/Sources/Pmm.cxx b/dev/ZKA/Sources/Pmm.cxx index 62015f41..b0855281 100644 --- a/dev/ZKA/Sources/Pmm.cxx +++ b/dev/ZKA/Sources/Pmm.cxx @@ -7,9 +7,9 @@ #include <KernelKit/DebugOutput.hxx> #include <NewKit/Pmm.hxx> -#if defined(__NEWOS_ARM64__) +#if defined(__ZKA_ARM64__) #include <HALKit/ARM64/Processor.hxx> -#endif // defined(__NEWOS_ARM64__) +#endif // defined(__ZKA_ARM64__) #if defined(__ZKA_AMD64__) #include <HALKit/AMD64/Processor.hxx> diff --git a/dev/ZKA/Sources/User.cxx b/dev/ZKA/Sources/User.cxx index 62b45e25..565f5197 100644 --- a/dev/ZKA/Sources/User.cxx +++ b/dev/ZKA/Sources/User.cxx @@ -186,8 +186,12 @@ namespace Kernel } fCurrentUser = &user; - Kernel::kcout << "newoskrnl: Logged in as: " << fCurrentUser->Name() << Kernel::endl; + if (fCurrentUser->Name()[0]) + Kernel::kcout << "newoskrnl: Logged in as: " << fCurrentUser->Name() << Kernel::endl; + else + + Kernel::kcout << "newoskrnl: Logged in as anon. " << Kernel::endl; return true; } diff --git a/dev/ZKA/amd64-efi.make b/dev/ZKA/amd64-efi.make index ad72bb00..5766b7b5 100644 --- a/dev/ZKA/amd64-efi.make +++ b/dev/ZKA/amd64-efi.make @@ -6,7 +6,7 @@ CC = x86_64-w64-mingw32-g++ LD = x86_64-w64-mingw32-ld CCFLAGS = -fshort-wchar -c -shared -D__ZKA_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions \ - -std=c++20 -D__NEWOS_SUPPORT_NX__ -I../Vendor -D__FSKIT_USE_NEWFS__ \ + -std=c++20 -D__ZKA_SUPPORT_NX__ -I../Vendor -D__FSKIT_USE_NEWFS__ \ -D__NEWOSKRNL__ -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -I./ -I../ -I../ZBA ASM = nasm diff --git a/dev/ZKA/arm64-efi.make b/dev/ZKA/arm64-efi.make index 410e7789..59bed1d5 100644 --- a/dev/ZKA/arm64-efi.make +++ b/dev/ZKA/arm64-efi.make @@ -5,7 +5,7 @@ CC = clang++ LD = lld-link -CCFLAGS = -fshort-wchar -c -ffreestanding -MMD -mno-red-zone -D__NEWOS_ARM64__ -fno-rtti -fno-exceptions -I./ \ +CCFLAGS = -fshort-wchar -c -ffreestanding -MMD -mno-red-zone -D__ZKA_ARM64__ -fno-rtti -fno-exceptions -I./ \ -target aarch64-unknown-windows \ -std=c++20 -D__FSKIT_USE_NEWFS__ -D__ZETA_MACHINE__ -D__NEWOSKRNL__ -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -I../ @@ -65,4 +65,4 @@ help: .PHONY: clean clean: - rm -f $(LDOBJ) $(wildcard *.o) $(KERNEL) + rm -f $(LDOBJ) $(wildcard *.o) $(KERNEL) |
