From 36b8e46de0e92aff31664470bb3587a91517ab99 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Thu, 3 Oct 2024 05:32:46 +0200 Subject: IMP: Fixes improvements and new APIs and implementations. - Add more threading API calls. - Moved /dev/zka/modules/ to /dev/modules/. - Add APM API inside /dev/modules. - Add SInt{x} types inside Defines.hxx. - Fix formatting inside PRM. Signed-off-by: Amlal EL Mahrouss --- dev/modules/ACPI/ACPI.hxx | 88 ++++++ dev/modules/ACPI/ACPIFactoryInterface.hxx | 60 ++++ dev/modules/AHCI/.gitkeep | 0 dev/modules/AHCI/AHCI.hxx | 370 +++++++++++++++++++++++ dev/modules/APM/APM.hxx | 34 +++ dev/modules/ATA/ATA.hxx | 156 ++++++++++ dev/modules/FB/FB.hxx | 154 ++++++++++ dev/modules/FB/Text.hxx | 178 +++++++++++ dev/modules/Flash/Flash.hxx | 21 ++ dev/modules/GLCG/GLCG.hxx | 9 + dev/modules/GPRS/.keepme | 0 dev/modules/HPET/.gitkeep | 0 dev/modules/HPET/Defines.hxx | 42 +++ dev/modules/IEEE802/.gitkeep | 0 dev/modules/LTE/.keepme | 0 dev/modules/LTE/IO.hxx | 28 ++ dev/modules/MBCI/Interface.hxx | 10 + dev/modules/MBCI/MBCI.hxx | 99 ++++++ dev/modules/NVME/.gitkeep | 0 dev/modules/NVME/NVME.hxx | 112 +++++++ dev/modules/OHCI/.gitkeep | 0 dev/modules/ReadMe.md | 7 + dev/modules/SCSI/.gitkeep | 0 dev/modules/SCSI/SCSI.hxx | 14 + dev/modules/WiFi/.gitkeep | 0 dev/modules/XHCI/.gitkeep | 0 dev/modules/XHCI/Defines.hxx | 70 +++++ dev/prm/pdf.hxx | 2 +- dev/sci/sci_base.hxx | 10 +- dev/sci/sci_err.hxx | 47 --- dev/sci/sci_lpc.hxx | 47 +++ dev/zba/BootKit/BootKit.hxx | 2 +- dev/zba/BootKit/Device.hxx | 2 +- dev/zba/BootKit/HW/ATA.hxx | 2 +- dev/zba/BootKit/HW/SATA.hxx | 2 +- dev/zba/amd64-efi.make | 10 +- dev/zba/src/HEL/AMD64/BootFileReader.cxx | 2 +- dev/zba/src/HEL/AMD64/BootMain.cxx | 4 +- dev/zba/src/Thread.cxx | 2 +- dev/zka/FirmwareKit/EFI/API.hxx | 2 +- dev/zka/HALKit/AMD64/HalACPIFactoryInterface.cxx | 2 +- dev/zka/HALKit/AMD64/HalAPICController.cxx | 2 +- dev/zka/HALKit/AMD64/HalCoreMPScheduler.cxx | 4 +- dev/zka/HALKit/AMD64/HalKernelMain.cxx | 4 +- dev/zka/HALKit/AMD64/HalTimer.cxx | 2 +- dev/zka/HALKit/AMD64/Storage/AHCI.cxx | 2 +- dev/zka/HALKit/AMD64/Storage/ATA-DMA.cxx | 2 +- dev/zka/HALKit/AMD64/Storage/ATA-PIO.cxx | 2 +- dev/zka/HALKit/ARM64/HalKernelMain.cxx | 4 +- dev/zka/Modules/ACPI/.gitkeep | 0 dev/zka/Modules/ACPI/ACPI.hxx | 88 ------ dev/zka/Modules/ACPI/ACPIFactoryInterface.hxx | 60 ---- dev/zka/Modules/AHCI/.gitkeep | 0 dev/zka/Modules/AHCI/AHCI.hxx | 370 ----------------------- dev/zka/Modules/APM/.gitkeep | 0 dev/zka/Modules/ATA/ATA.hxx | 156 ---------- dev/zka/Modules/FB/FB.hxx | 154 ---------- dev/zka/Modules/FB/Text.hxx | 178 ----------- dev/zka/Modules/Flash/Flash.hxx | 21 -- dev/zka/Modules/GLCG/.keepme | 0 dev/zka/Modules/GPRS/.keepme | 0 dev/zka/Modules/HPET/.gitkeep | 0 dev/zka/Modules/HPET/Defines.hxx | 42 --- dev/zka/Modules/IEEE802/.gitkeep | 0 dev/zka/Modules/LTE/.keepme | 0 dev/zka/Modules/LTE/IO.hxx | 28 -- dev/zka/Modules/MBCI/Interface.hxx | 10 - dev/zka/Modules/MBCI/MBCI.hxx | 99 ------ dev/zka/Modules/NVME/.gitkeep | 0 dev/zka/Modules/NVME/NVME.hxx | 112 ------- dev/zka/Modules/OHCI/.gitkeep | 0 dev/zka/Modules/ReadMe.md | 12 - dev/zka/Modules/SCSI/.gitkeep | 0 dev/zka/Modules/SCSI/SCSI.hxx | 14 - dev/zka/Modules/WiFi/.gitkeep | 0 dev/zka/Modules/XHCI/.gitkeep | 0 dev/zka/Modules/XHCI/Defines.hxx | 70 ----- dev/zka/NewKit/Defines.hxx | 4 + dev/zka/StorageKit/SCSI.hxx | 2 +- dev/zka/amd64-efi.make | 8 +- dev/zka/src/DriveMgr.cxx | 6 +- dev/zka/src/FS/NeFS.cxx | 6 +- dev/zka/src/Stop.cxx | 6 +- 83 files changed, 1552 insertions(+), 1504 deletions(-) create mode 100644 dev/modules/ACPI/ACPI.hxx create mode 100644 dev/modules/ACPI/ACPIFactoryInterface.hxx create mode 100644 dev/modules/AHCI/.gitkeep create mode 100644 dev/modules/AHCI/AHCI.hxx create mode 100644 dev/modules/APM/APM.hxx create mode 100644 dev/modules/ATA/ATA.hxx create mode 100644 dev/modules/FB/FB.hxx create mode 100644 dev/modules/FB/Text.hxx create mode 100644 dev/modules/Flash/Flash.hxx create mode 100644 dev/modules/GLCG/GLCG.hxx create mode 100644 dev/modules/GPRS/.keepme create mode 100644 dev/modules/HPET/.gitkeep create mode 100644 dev/modules/HPET/Defines.hxx create mode 100644 dev/modules/IEEE802/.gitkeep create mode 100644 dev/modules/LTE/.keepme create mode 100644 dev/modules/LTE/IO.hxx create mode 100644 dev/modules/MBCI/Interface.hxx create mode 100644 dev/modules/MBCI/MBCI.hxx create mode 100644 dev/modules/NVME/.gitkeep create mode 100644 dev/modules/NVME/NVME.hxx create mode 100644 dev/modules/OHCI/.gitkeep create mode 100644 dev/modules/ReadMe.md create mode 100644 dev/modules/SCSI/.gitkeep create mode 100644 dev/modules/SCSI/SCSI.hxx create mode 100644 dev/modules/WiFi/.gitkeep create mode 100644 dev/modules/XHCI/.gitkeep create mode 100644 dev/modules/XHCI/Defines.hxx delete mode 100644 dev/sci/sci_err.hxx create mode 100644 dev/sci/sci_lpc.hxx delete mode 100644 dev/zka/Modules/ACPI/.gitkeep delete mode 100644 dev/zka/Modules/ACPI/ACPI.hxx delete mode 100644 dev/zka/Modules/ACPI/ACPIFactoryInterface.hxx delete mode 100644 dev/zka/Modules/AHCI/.gitkeep delete mode 100644 dev/zka/Modules/AHCI/AHCI.hxx delete mode 100644 dev/zka/Modules/APM/.gitkeep delete mode 100644 dev/zka/Modules/ATA/ATA.hxx delete mode 100644 dev/zka/Modules/FB/FB.hxx delete mode 100644 dev/zka/Modules/FB/Text.hxx delete mode 100644 dev/zka/Modules/Flash/Flash.hxx delete mode 100644 dev/zka/Modules/GLCG/.keepme delete mode 100644 dev/zka/Modules/GPRS/.keepme delete mode 100644 dev/zka/Modules/HPET/.gitkeep delete mode 100644 dev/zka/Modules/HPET/Defines.hxx delete mode 100644 dev/zka/Modules/IEEE802/.gitkeep delete mode 100644 dev/zka/Modules/LTE/.keepme delete mode 100644 dev/zka/Modules/LTE/IO.hxx delete mode 100644 dev/zka/Modules/MBCI/Interface.hxx delete mode 100644 dev/zka/Modules/MBCI/MBCI.hxx delete mode 100644 dev/zka/Modules/NVME/.gitkeep delete mode 100644 dev/zka/Modules/NVME/NVME.hxx delete mode 100644 dev/zka/Modules/OHCI/.gitkeep delete mode 100644 dev/zka/Modules/ReadMe.md delete mode 100644 dev/zka/Modules/SCSI/.gitkeep delete mode 100644 dev/zka/Modules/SCSI/SCSI.hxx delete mode 100644 dev/zka/Modules/WiFi/.gitkeep delete mode 100644 dev/zka/Modules/XHCI/.gitkeep delete mode 100644 dev/zka/Modules/XHCI/Defines.hxx (limited to 'dev') diff --git a/dev/modules/ACPI/ACPI.hxx b/dev/modules/ACPI/ACPI.hxx new file mode 100644 index 00000000..00ba4f9e --- /dev/null +++ b/dev/modules/ACPI/ACPI.hxx @@ -0,0 +1,88 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#ifndef __ACPI__ +#define __ACPI__ + +/** + https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html +*/ + +#include + +namespace Kernel +{ + class PACKED SDT + { + public: + Char Signature[4]; + UInt32 Length; + UInt8 Revision; + Char Checksum; + Char OemId[6]; + Char OemTableId[8]; + UInt32 OemRev; + UInt32 CreatorID; + UInt32 CreatorRevision; + }; + + class PACKED RSDP : public SDT + { + public: + UInt32 RsdtAddress; + UIntPtr XsdtAddress; + UInt8 ExtendedChecksum; + UInt8 Reserved0[3]; + }; + + class PACKED ConfigHeader + { + public: + UInt64 BaseAddress; + UInt16 PciSegGroup; + UInt8 StartBus; + UInt8 EndBus; + UInt32 Reserved; + }; + + enum ACPI_ADDRESS_SPACE_KIND : UInt8 + { + eSystemMemory = 0, + eSystemIO = 1, + ePci = 2, + eController = 3, + eSmBus = 4, + eCount = 5, + eInvalid = 0xFF, + }; + + class PACKED ACPI_ADDRESS final + { + public: + UInt8 AddressSpaceId; + UInt8 RegisterBitWidth; + UInt8 RegisterBitOffset; + UInt8 Reserved; + UIntPtr Address; + }; + + class PACKED RSDT final + { + public: + Char Signature[4]; + UInt32 Length; + UInt8 Revision; + Char Checksum; + Char OemId[6]; + Char OemTableId[8]; + UInt32 OemRev; + UInt32 CreatorID; + UInt32 CreatorRevision; + UInt32 AddressArr[]; + }; +} // namespace Kernel + +#endif // !__ACPI__ diff --git a/dev/modules/ACPI/ACPIFactoryInterface.hxx b/dev/modules/ACPI/ACPIFactoryInterface.hxx new file mode 100644 index 00000000..3d16d5a1 --- /dev/null +++ b/dev/modules/ACPI/ACPIFactoryInterface.hxx @@ -0,0 +1,60 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#ifndef __MOD_ACPI_HXX__ +#define __MOD_ACPI_HXX__ + +#include +#include +#include +#include +#include + +namespace Kernel +{ + class ACPIFactoryInterface; + + typedef ACPIFactoryInterface PowerFactoryInterface; + + class ACPIFactoryInterface final + { + public: + explicit ACPIFactoryInterface(voidPtr rsdPtr); + ~ACPIFactoryInterface() = default; + + ACPIFactoryInterface& operator=(const ACPIFactoryInterface&) = default; + ACPIFactoryInterface(const ACPIFactoryInterface&) = default; + + public: + Void Shutdown(); // shutdown + Void Reboot(); // soft-reboot + + public: + /// @brief Descriptor find factory. + /// @param signature The signature of the descriptor table (MADT, ACPI...) + /// @return the blob inside an ErrorOr object. + ErrorOr Find(const Char* signature); + + /// @brief Checksum factory. + /// @param checksum the data to checksum + /// @param len it's size + /// @return if it succeed + bool Checksum(const Char* checksum, SSizeT len); // watch for collides! + + public: + ErrorOr operator[](const Char* signature) + { + return this->Find(signature); + } + + private: + VoidPtr fRsdp; // pointer to root descriptor. + SSizeT fEntries; // number of entries, -1 tells that no invalid entries were + // found. + }; +} // namespace Kernel + +#endif // !__MOD_ACPI_HXX__ diff --git a/dev/modules/AHCI/.gitkeep b/dev/modules/AHCI/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/modules/AHCI/AHCI.hxx b/dev/modules/AHCI/AHCI.hxx new file mode 100644 index 00000000..dd9806db --- /dev/null +++ b/dev/modules/AHCI/AHCI.hxx @@ -0,0 +1,370 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + File: Defines.hxx + Purpose: AHCI header. + + Revision History: + + 03/02/24: Added file (amlel) + +------------------------------------------- */ + +#pragma once + +#include +#include + +// Forward declarations of structs. + +#define kAHCISectorSize (512U) + +struct HbaPort; +struct FisData; +struct FisRegD2H; +struct FisRegH2D; + +/// @brief Frame information type. +enum +{ + kFISTypeRegH2D = 0x27, // Register FIS - host to device + kFISTypeRegD2H = 0x34, // Register FIS - device to host + kFISTypeDMAAct = 0x39, // DMA activate FIS - device to host + kFISTypeDMASetup = 0x41, // DMA setup FIS - bidirectional + kFISTypeData = 0x46, // Data FIS - bidirectional + kFISTypeBIST = 0x58, // BIST activate FIS - bidirectional + kFISTypePIOSetup = 0x5F, // PIO setup FIS - device to host + kFISTypeDevBits = 0xA1, // Set device bits FIS - device to host +}; + +enum +{ + kAHCICmdIdentify = 0xEC, + kAHCICmdReadDma = 0xC8, + kAHCICmdReadDmaEx = 0x25, + kAHCICmdWriteDma = 0xCA, + kAHCICmdWriteDmaEx = 0x35 +}; + +typedef struct FisRegH2D final +{ + // DWORD 0 + Kernel::UInt8 FisType; // FIS_TYPE_REG_H2D + + Kernel::UInt8 PortMul : 4; // Port multiplier + Kernel::UInt8 Reserved0 : 3; // Reserved + Kernel::UInt8 CmdOrCtrl : 1; // 1: Command, 0: Control + + Kernel::UInt8 Command; // Command register + Kernel::UInt8 Featurel; // Feature register, 7:0 + + // DWORD 1 + Kernel::UInt8 Lba0; // LBA low register, 7:0 + Kernel::UInt8 Lba1; // LBA mid register, 15:8 + Kernel::UInt8 Lba2; // LBA high register, 23:16 + Kernel::UInt8 Device; // Device register + + // DWORD 2 + Kernel::UInt8 Lba3; // LBA register, 31:24 + Kernel::UInt8 Lba4; // LBA register, 39:32 + Kernel::UInt8 Lba5; // LBA register, 47:40 + Kernel::UInt8 FeatureHigh; // Feature register, 15:8 + + // DWORD 3 + Kernel::UInt8 CountLow; // Count register, 7:0 + Kernel::UInt8 CountHigh; // Count register, 15:8 + Kernel::UInt8 Icc; // Isochronous command completion + Kernel::UInt8 Control; // Control register + + // DWORD 4 + Kernel::UInt8 Reserved1[4]; // Reserved +} FisRegH2D; + +typedef struct FisRegD2H final +{ + // DWORD 0 + Kernel::UInt8 FisType; // FIS_TYPE_REG_D2H + + Kernel::UInt8 PortMul : 4; // Port multiplier + Kernel::UInt8 Reserved0 : 2; // Reserved + Kernel::UInt8 InterruptBit : 1; // Interrupt bit + Kernel::UInt8 Reserved1 : 1; // Reserved + + Kernel::UInt8 Status; // Status register + Kernel::UInt8 Rrror; // Error register + + // DWORD 1 + Kernel::UInt8 Lba0; // LBA low register, 7:0 + Kernel::UInt8 Lba1; // LBA mid register, 15:8 + Kernel::UInt8 Lba2; // LBA high register, 23:16 + Kernel::UInt8 Device; // Device register + + // DWORD 2 + Kernel::UInt8 Lba3; // LBA register, 31:24 + Kernel::UInt8 Lba4; // LBA register, 39:32 + Kernel::UInt8 Lba5; // LBA register, 47:40 + Kernel::UInt8 Rsv2; // Reserved + + // DWORD 3 + Kernel::UInt8 CountLow; // Count register, 7:0 + Kernel::UInt8 CountHigh; // Count register, 15:8 + Kernel::UInt8 Rsv3[2]; // Reserved + + // DWORD 4 + Kernel::UInt8 Rsv4[4]; // Reserved +} FisRegD2H; + +typedef struct FisData final +{ + // DWORD 0 + Kernel::UInt8 FisType; // FIS_TYPE_DATA + + Kernel::UInt8 PortMul : 4; // Port multiplier + Kernel::UInt8 Reserved0 : 4; // Reserved + + Kernel::UInt8 Reserved1[2]; // Reserved + + // DWORD 1 ~ N + Kernel::UInt32 Data[1]; // Payload +} FisData; + +typedef struct FisPioSetup final +{ + // DWORD 0 + Kernel::UInt8 FisType; // FIS_TYPE_PIO_SETUP + + Kernel::UInt8 PortMul : 4; // Port multiplier + Kernel::UInt8 Reserved0 : 1; // Reserved + Kernel::UInt8 DTD : 1; // Data transfer direction, 1 - device to host + Kernel::UInt8 InterruptBit : 1; // Interrupt bit + Kernel::UInt8 Reserved1 : 1; + + Kernel::UInt8 Status; // Status register + Kernel::UInt8 Error; // Error register + + // DWORD 1 + Kernel::UInt8 Lba0; // LBA low register, 7:0 + Kernel::UInt8 Lba1; // LBA mid register, 15:8 + Kernel::UInt8 Lba2; // LBA high register, 23:16 + Kernel::UInt8 Device; // Device register + + // DWORD 2 + Kernel::UInt8 Lba3; // LBA register, 31:24 + Kernel::UInt8 Lba4; // LBA register, 39:32 + Kernel::UInt8 Lba5; // LBA register, 47:40 + Kernel::UInt8 Rsv2; // Reserved + + // DWORD 3 + Kernel::UInt8 CountLow; // Count register, 7:0 + Kernel::UInt8 CountHigh; // Count register, 15:8 + Kernel::UInt8 Rsv3; // Reserved + Kernel::UInt8 EStatus; // New value of status register + + // DWORD 4 + Kernel::UInt16 TranferCount; // Transfer count + Kernel::UInt8 Rsv4[2]; // Reserved +} FisPioSetup; + +typedef struct FisDmaSetup final +{ + // DWORD 0 + Kernel::UInt8 FisType; // FIS_TYPE_DMA_SETUP + + Kernel::UInt8 PortMul : 4; // Port multiplier + Kernel::UInt8 Reserved0 : 1; // Reserved + Kernel::UInt8 DTD : 1; // Data transfer direction, 1 - device to host + Kernel::UInt8 InterruptBit : 1; // Interrupt bit + Kernel::UInt8 AutoEnable : 1; // Auto-activate. Specifies if DMA Activate FIS is needed + + Kernel::UInt8 Reserved1[2]; // Reserved + + // DWORD 1&2 + 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. + + // DWORD 3 + Kernel::UInt32 Rsvd; // More reserved + + // DWORD 4 + Kernel::UInt32 DmabufOffset; // Byte offset into buffer. First 2 bits must be 0 + + // DWORD 5 + Kernel::UInt32 TransferCount; // Number of bytes to transfer. Bit 0 must be 0 + + // DWORD 6 + Kernel::UInt32 Reserved3; // Reserved +} FisDmaSetup; + +typedef struct FisDevBits final +{ + // DWORD 0 + Kernel::UInt8 FisType; // FIS_TYPE_DMA_SETUP (A1h) + + Kernel::UInt8 Reserved0 : 5; // Reserved + Kernel::UInt8 R0 : 1; + Kernel::UInt8 InterruptBit : 1; + Kernel::UInt8 N : 1; + + Kernel::UInt8 StatusLow : 3; + Kernel::UInt8 R1 : 1; + Kernel::UInt8 StatusHigh : 3; + + Kernel::UInt8 R2 : 1; + Kernel::UInt8 Error; + + // DWORD 1 + Kernel::UInt32 Act; +} FisDevBits; + +/// \brief Enable AHCI device bit in GHC register. +#ifndef kAhciGHC_AE +#define kAhciGHC_AE (31) +#endif //! ifndef kAhciGHC_AE + +typedef struct HbaPort final +{ + Kernel::UInt32 Clb; // 0x00, command list base address, 1K-byte aligned + Kernel::UInt32 Clbu; // 0x04, command list base address upper 32 bits + Kernel::UInt32 Fb; // 0x08, FIS base address, 256-byte aligned + Kernel::UInt32 Fbu; // 0x0C, FIS base address upper 32 bits + Kernel::UInt32 Is; // 0x10, interrupt status + Kernel::UInt32 Ie; // 0x14, interrupt enable + Kernel::UInt32 Cmd; // 0x18, command and status + Kernel::UInt32 Reserved0; // 0x1C, Reserved + Kernel::UInt32 Tfd; // 0x20, task file data + Kernel::UInt32 Sig; // 0x24, signature + Kernel::UInt32 Ssts; // 0x28, SATA status (SCR0:SStatus) + Kernel::UInt32 Sctl; // 0x2C, SATA control (SCR2:SControl) + 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 Fbs; // 0x40, FIS-based switch control + Kernel::UInt32 Reserved1[11]; // 0x44 ~ 0x6F, Reserved + Kernel::UInt32 Vendor[4]; // 0x70 ~ 0x7F, vendor specific +} HbaPort; + +typedef struct HbaMem final +{ + // 0x00 - 0x2B, Generic Host Control + Kernel::UInt32 Cap; // 0x00, Host capability + Kernel::UInt32 Ghc; // 0x04, Global host control + Kernel::UInt32 Is; // 0x08, Interrupt status + Kernel::UInt32 Pi; // 0x0C, Port implemented + Kernel::UInt32 Vs; // 0x10, Version + Kernel::UInt32 Ccc_ctl; // 0x14, Command completion coalescing control + Kernel::UInt32 Ccc_pts; // 0x18, Command completion coalescing ports + Kernel::UInt32 Em_loc; // 0x1C, Enclosure management location + Kernel::UInt32 Em_ctl; // 0x20, Enclosure management control + Kernel::UInt32 Cap2; // 0x24, Host capabilities extended + Kernel::UInt32 Bohc; // 0x28, BIOS/OS handoff control and status + + Kernel::UInt16 Resv0; + Kernel::UInt32 Resv2; + + HbaPort Ports[1]; // 1 ~ 32, 32 is the max ahci devices per controller. +} HbaMem; + +typedef struct HbaCmdHeader final +{ + // DW0 + Kernel::UInt8 Cfl : 5; // Command FIS length in DWORDS, 2 ~ 16 + Kernel::UInt8 Atapi : 1; // ATAPI + Kernel::UInt8 Write : 1; // Write, 1: H2D, 0: D2H + Kernel::UInt8 Prefetchable : 1; // Prefetchable + + Kernel::UInt8 Reset : 1; // Reset + Kernel::UInt8 BIST : 1; // BIST + Kernel::UInt8 Clear : 1; // Clear busy upon R_OK + Kernel::UInt8 Reserved0 : 1; // Reserved + Kernel::UInt8 Pmp : 4; // Port multiplier port + + Kernel::UInt16 Prdtl; // Physical region descriptor table length in entries + volatile Kernel::UInt32 Prdbc; // Physical region descriptor byte count transferred + + Kernel::UInt32 Ctba; // Command table descriptor base address + Kernel::UInt32 Ctbau; // Command table descriptor base address upper 32 bits + + Kernel::UInt32 Reserved1[4]; // Reserved +} HbaCmdHeader; + +typedef struct HbaFis final +{ + // 0x00 + FisDmaSetup Dsfis; // DMA Setup FIS + Kernel::UInt8 Pad0[4]; + // 0x20 + FisPioSetup Psfis; // PIO Setup FIS + Kernel::UInt8 Pad1[12]; + // 0x40 + FisRegD2H Rfis; // Register – Device to Host FIS + Kernel::UInt8 Pad2[4]; + // 0x58 + FisDevBits Sdbfis; // Set Device Bit FIS + // 0x60 + Kernel::UInt8 Ufis[64]; + // 0xA0 + Kernel::UInt8 Rsv[0x100 - 0xA0]; +} HbaFis; + +typedef struct HbaPrdtEntry final +{ + Kernel::UInt32 Dba; // Data base address + Kernel::UInt32 Dbau; // Data base address upper 32 bits + Kernel::UInt32 Reserved0; // Reserved + // DW3 + Kernel::UInt32 Dbc : 22; // Byte count, 4M max + Kernel::UInt32 Reserved1 : 9; // Reserved + Kernel::UInt32 InterruptBit : 1; // Interrupt on completion +} HbaPrdtEntry; + +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 prdtEntries[1]; // Physical region descriptor table entries, 0 ~ 65535 +} HbaCmdTbl; + +/* EOF */ + +#if defined(__AHCI__) + +/// @brief Initializes an AHCI disk. +/// @param PortsImplemented the amount of port that have been detected. +/// @return +Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented); + +Kernel::Boolean drv_std_detected(Kernel::Void); + +/// @brief Read from disk. +/// @param Lba +/// @param Buf +/// @param SectorSz +/// @param Size +/// @return +Kernel::Void drv_std_read(Kernel::UInt64 Lba, Kernel::Char* Buf, Kernel::SizeT SectorSz, Kernel::SizeT Size); + +/// @brief Write to disk. +/// @param Lba +/// @param Buf +/// @param SectorSz +/// @param Size +/// @return +Kernel::Void drv_std_write(Kernel::UInt64 Lba, Kernel::Char* Buf, Kernel::SizeT SectorSz, Kernel::SizeT Size); + +/// @brief get sector count. +Kernel::SizeT drv_get_sector_count(); + +/// @brief get device size. +Kernel::SizeT drv_get_size(); + +/// @brief get sector count. +Kernel::SizeT drv_get_sector_count(); + +/// @brief get device size. +Kernel::SizeT drv_get_size(); + +#endif // ifdef __NEWOSKRNL__ diff --git a/dev/modules/APM/APM.hxx b/dev/modules/APM/APM.hxx new file mode 100644 index 00000000..abcfb468 --- /dev/null +++ b/dev/modules/APM/APM.hxx @@ -0,0 +1,34 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#pragma once + +#include + +namespace Kernel +{ + typedef Int32 APMPowerCmd; + + enum + { + kAPMPowerCommandStop = 0x01, + kAPMPowerCommandStart = 0x02, + kAPMPowerCommandSleep = 0x04, + kAPMPowerCommandSWakeup = 0x06 + }; + + /// @brief Send a APM command into it's own DMA space. + /// @param base_dma the DMA base address. + /// @param cmd the command. + /// @return status code. + EXTERN_C Int32 apm_send_dma_command(Ptr64 base_dma, APMPowerCmd cmd); + + /// @brief Send a APM command into it's own IO space. + /// @param base_dma the IO base port. + /// @param cmd the command. + /// @return status code. + EXTERN_C Int32 apm_send_io_command(UInt16 base_port, APMPowerCmd cmd); +} // namespace Kernel \ No newline at end of file diff --git a/dev/modules/ATA/ATA.hxx b/dev/modules/ATA/ATA.hxx new file mode 100644 index 00000000..f550ddc6 --- /dev/null +++ b/dev/modules/ATA/ATA.hxx @@ -0,0 +1,156 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + File: Defines.hxx + Purpose: ATA header. + + Revision History: + + 03/02/24: Added file (amlel) + +------------------------------------------- */ + +#pragma once + +#ifndef __AHCI__ + +#include +#include + +///! Status register +#define ATA_SR_BSY 0x80 +#define ATA_SR_DRDY 0x40 +#define ATA_SR_DF 0x20 +#define ATA_SR_DSC 0x10 +#define ATA_SR_DRQ 0x08 +#define ATA_SR_CORR 0x04 +#define ATA_SR_IDX 0x02 +#define ATA_SR_ERR 0x01 + +///! Error register +#define ATA_ER_BBK 0x80 +#define ATA_ER_UNC 0x40 +#define ATA_ER_MC 0x20 +#define ATA_ER_IDNF 0x10 +#define ATA_ER_MCR 0x08 +#define ATA_ER_ABRT 0x04 +#define ATA_ER_TK0NF 0x02 +#define ATA_ER_AMNF 0x01 + +#define ATA_CMD_READ_PIO 0x20 +#define ATA_CMD_READ_PIO_EXT 0x24 +#define ATA_CMD_READ_DMA 0xC8 +#define ATA_CMD_READ_DMA_EXT 0x25 +#define ATA_CMD_WRITE_PIO 0x30 +#define ATA_CMD_WRITE_PIO_EXT 0x34 +#define ATA_CMD_WRITE_DMA 0xCA +#define ATA_CMD_WRITE_DMA_EXT 0x35 +#define ATA_CMD_CACHE_FLUSH 0xE7 +#define ATA_CMD_CACHE_FLUSH_EXT 0xEA +#define ATA_CMD_PACKET 0xA0 +#define ATA_CMD_IDENTIFY_PACKET 0xA1 +#define ATA_CMD_IDENTIFY 0xEC + +///! ident offsets, use with data that we got from ATA_CMD_IDENTIFY. +#define ATA_IDENT_DEVICE_TYPE 0 +#define ATA_IDENT_CYLINDERS 2 +#define ATA_IDENT_HEADS 6 +#define ATA_IDENT_SECTORS 12 +#define ATA_IDENT_SERIAL 20 +#define ATA_IDENT_MODEL 54 +#define ATA_IDENT_CAPABILITIES 98 +#define ATA_IDENT_FIELDVALID 106 +#define ATA_IDENT_MAX_LBA 120 +#define ATA_IDENT_COMMANDSETS 164 +#define ATA_IDENT_MAX_LBA_EXT 200 + +#define ATA_MASTER 0x00 +#define ATA_SLAVE 0x01 + +///! Register +#define ATA_REG_DATA 0x00 +#define ATA_REG_ERROR 0x01 +#define ATA_REG_FEATURES 0x01 +#define ATA_REG_SEC_COUNT0 0x02 +#define ATA_REG_LBA0 0x03 +#define ATA_REG_LBA1 0x04 +#define ATA_REG_LBA2 0x05 +#define ATA_REG_HDDEVSEL 0x06 +#define ATA_REG_COMMAND 0x07 +#define ATA_REG_STATUS 0x07 +#define ATA_REG_SEC_COUNT1 0x08 +#define ATA_REG_LBA3 0x09 +#define ATA_REG_LBA4 0x0A +#define ATA_REG_LBA5 0x0B +#define ATA_REG_CONTROL 0x0C +#define ATA_REG_ALT_STATUS 0x0C +#define ATA_REG_DEV_ADDRESS 0x0D + +#define ATA_REG_NEIN 0x01 + +#define ATA_PRIMARY_IO 0x1F0 +#define ATA_SECONDARY_IO 0x170 +#define ATA_PRIMARY_DCR_AS 0x3F6 +#define ATA_SECONDARY_DCR_AS 0x376 + +///! Irq +#define ATA_PRIMARY_IRQ 14 +#define ATA_SECONDARY_IRQ 15 + +///! Channels +#define ATA_PRIMARY 0x00 +#define ATA_SECONDARY 0x01 + +#define ATA_CYL_LOW 3 +#define ATA_CYL_MID 4 +#define ATA_CYL_HIGH 5 + +///! IO Direction +#define ATA_READ 0x00 +#define ATA_WRITE 0x013 + +#define ATA_PRIMARY_SEL 0xA0 +#define ATA_SECONDARY_SEL 0xB0 + +///! ATA address register. +#define ATA_ADDRESS1(x) (x + 3) +#define ATA_ADDRESS2(x) (x + 4) +#define ATA_ADDRESS3(x) (x + 5) + +///! ATA command register. +#define ATA_COMMAND(x) (x + 7) + +#define kATASectorSize (512U) + +enum +{ + kATADevicePATA, + kATADeviceSATA, + kATADevicePATA_PI, + kATADeviceSATA_PI, + kATADeviceCount, +}; + +#if defined(__ATA_PIO__) || defined(__ATA_DMA__) + +Kernel::Boolean drv_std_init(Kernel::UInt16 Bus, Kernel::UInt8 Drive, Kernel::UInt16& OutBus, Kernel::UInt8& OutMaster); + +Kernel::Boolean drv_std_detected(Kernel::Void); + +Kernel::Void drv_std_select(Kernel::UInt16 Bus); + +Kernel::Boolean drv_std_wait_io(Kernel::UInt16 IO); + +Kernel::Void drv_std_read(Kernel::UInt64 Lba, Kernel::UInt16 IO, Kernel::UInt8 Master, Kernel::Char* Buf, Kernel::SizeT SectorSz, Kernel::SizeT Size); + +Kernel::Void drv_std_write(Kernel::UInt64 Lba, Kernel::UInt16 IO, Kernel::UInt8 Master, Kernel::Char* Buf, Kernel::SizeT SectorSz, Kernel::SizeT Size); + +/// @brief get sector count. +Kernel::SizeT drv_get_sector_count(); + +/// @brief get device size. +Kernel::SizeT drv_get_size(); + +#endif // ifdef __NEWOSKRNL__ +#endif // ifndef __ATA_PIO__ || __AHCI__ diff --git a/dev/modules/FB/FB.hxx b/dev/modules/FB/FB.hxx new file mode 100644 index 00000000..a98eeafe --- /dev/null +++ b/dev/modules/FB/FB.hxx @@ -0,0 +1,154 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#pragma once + +#include + +#define CGInit() Kernel::SizeT __CG_CURSOR = 0 + +#define CGColor(R, G, B) RGB(R, G, B) + +#define cCGClearClr CGColor(0x0, 0x0, 0x0) + +#define CGFini() __CG_CURSOR = 0 + +/// @brief Performs OR drawing on the framebuffer. +#define CGDrawBitMapInRegionA(_BitMp, _Height, _Width, _BaseX, _BaseY) \ + __CG_CURSOR = 0; \ + \ + for (Kernel::SizeT i = _BaseX; i < (_Height + _BaseX); ++i) \ + { \ + for (Kernel::SizeT u = _BaseY; u < (_Width + _BaseY); ++u) \ + { \ + *(((Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ + i + \ + 4 * u))) |= (_BitMp)[__CG_CURSOR]; \ + \ + ++__CG_CURSOR; \ + } \ + } + +/// @brief Draws a resource. +#define CGDrawBitMapInRegion(_BitMp, _Height, _Width, _BaseX, _BaseY) \ + __CG_CURSOR = 0; \ + \ + for (Kernel::SizeT i = _BaseX; i < (_Height + _BaseX); ++i) \ + { \ + for (Kernel::SizeT u = _BaseY; u < (_Width + _BaseY); ++u) \ + { \ + *(((Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ + i + \ + 4 * u))) = (_BitMp)[__CG_CURSOR]; \ + \ + ++__CG_CURSOR; \ + } \ + } + +#define CGDrawBitMapInRegionToRgn(_Rgn, _BitMp, _Height, _Width, _BaseX, _BaseY) \ + __CG_CURSOR = 0; \ + \ + for (Kernel::SizeT i = _BaseX; i < (_Height + _BaseX); ++i) \ + { \ + for (Kernel::SizeT u = _BaseY; u < (_Width + _BaseY); ++u) \ + { \ + *(((Kernel::UInt32*)(_Rgn + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ + i + \ + 4 * u))) = (_BitMp)[__CG_CURSOR]; \ + \ + ++__CG_CURSOR; \ + } \ + } + +/// @brief Cleans a resource. +#define CGClearRegion(_Height, _Width, _BaseX, _BaseY) \ + \ + for (Kernel::SizeT i = _BaseX; i < _Height + _BaseX; ++i) \ + { \ + for (Kernel::SizeT u = _BaseY; u < _Width + _BaseY; ++u) \ + { \ + *(((volatile Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ + i + \ + 4 * u))) = cCGClearClr; \ + } \ + } + +/// @brief Draws inside a zone. +#define CGDrawInRegion(_Clr, _Height, _Width, _BaseX, _BaseY) \ + \ + for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ + { \ + for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \ + { \ + *(((volatile Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ + x_base + \ + 4 * y_base))) = _Clr; \ + } \ + } + +/// @brief Draws inside a zone. +#define CGDrawInRegionToRgn(_Rgn, _Clr, _Height, _Width, _BaseX, _BaseY) \ + __CG_CURSOR = 0; \ + \ + for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ + { \ + for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \ + { \ + *(((volatile Kernel::UInt32*)(_Rgn + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ + x_base + \ + 4 * y_base))) = _Clr[__CG_CURSOR]; \ + ++__CG_CURSOR; \ + } \ + } + +#define CGDrawInRegionToVideoRgn(_VideoRgn, _Clr, _Height, _Width, _BaseX, _BaseY) \ + __CG_CURSOR = 0; \ + \ + for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ + { \ + for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \ + { \ + *(((volatile Kernel::UInt32*)(_VideoRgn + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ + x_base + \ + 4 * y_base))) = _Clr; \ + ++__CG_CURSOR; \ + } \ + } + +#define CGDrawInRegionToVideoRgnA(_VideoRgn, _Clr, _Height, _Width, _BaseX, _BaseY) \ + __CG_CURSOR = 0; \ + \ + for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ + { \ + for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \ + { \ + *(((volatile Kernel::UInt32*)(_VideoRgn + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ + x_base + \ + 4 * y_base))) |= _Clr; \ + ++__CG_CURSOR; \ + } \ + } + +#define CGDrawInRegionA(_Clr, _Height, _Width, _BaseX, _BaseY) \ + \ + for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ + { \ + for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \ + { \ + *(((volatile Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ + x_base + \ + 4 * y_base))) |= _Clr; \ + } \ + } diff --git a/dev/modules/FB/Text.hxx b/dev/modules/FB/Text.hxx new file mode 100644 index 00000000..b2fd1ac6 --- /dev/null +++ b/dev/modules/FB/Text.hxx @@ -0,0 +1,178 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#pragma once + +#include +#include + +#define FONT_SIZE_X 8 +#define FONT_SIZE_Y 8 +#define FONT_NOF_CHARS 128 + +inline const Kernel::UInt8 cFontBitmap[FONT_NOF_CHARS][FONT_SIZE_X] = { + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space) + {0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!) + {0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (") + {0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#) + {0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($) + {0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%) + {0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&) + {0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (') + {0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (() + {0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ()) + {0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*) + {0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,) + {0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.) + {0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/) + {0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0) + {0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1) + {0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2) + {0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3) + {0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4) + {0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5) + {0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6) + {0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7) + {0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8) + {0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9) + {0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:) + {0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (;) + {0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<) + {0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=) + {0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>) + {0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?) + {0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@) + {0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A) + {0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B) + {0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C) + {0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D) + {0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E) + {0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F) + {0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G) + {0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H) + {0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I) + {0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J) + {0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K) + {0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L) + {0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M) + {0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N) + {0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O) + {0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P) + {0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q) + {0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R) + {0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S) + {0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T) + {0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U) + {0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V) + {0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W) + {0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X) + {0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y) + {0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z) + {0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([) + {0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\) + {0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (]) + {0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_) + {0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`) + {0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a) + {0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b) + {0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c) + {0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d) + {0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e) + {0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f) + {0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g) + {0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h) + {0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i) + {0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j) + {0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k) + {0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l) + {0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m) + {0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n) + {0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o) + {0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p) + {0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q) + {0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r) + {0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s) + {0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t) + {0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u) + {0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v) + {0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w) + {0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x) + {0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y) + {0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z) + {0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({) + {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|) + {0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (}) + {0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // U+007F + +}; + +inline Kernel::Void CGRenderStringFromBitMap(const Kernel::UInt8* bitmap, const Kernel::SizeT& x_sz, const Kernel::SizeT& y_sz, Kernel::Int32& x_dst, Kernel::Int32& y_dst, Kernel::Int32& color) +{ + Kernel::Int32 x, y; + Kernel::Int32 set; + + x = 0; + y = 0; + set = 0; + + for (; y < y_sz; ++y) + { + for (x = 0; x < x_sz; ++x) + { + set = bitmap[x] & (1 << y); + + if (set) + { + CGDrawInRegion(color, 1, 1, ((x_dst) + x), ((y_dst) + y)); + } + } + } +} + +inline Kernel::Void CGDrawString(const Kernel::Char* text, Kernel::Int32 x_dst, Kernel::Int32 y_dst, Kernel::Int32 color) +{ + for (Kernel::SizeT i = 0; text[i] != 0; ++i) + { + CGRenderStringFromBitMap(&cFontBitmap[text[i]][0], FONT_SIZE_X, FONT_SIZE_Y, x_dst, y_dst, color); + y_dst += FONT_SIZE_Y; + } +} diff --git a/dev/modules/Flash/Flash.hxx b/dev/modules/Flash/Flash.hxx new file mode 100644 index 00000000..ccea5a9a --- /dev/null +++ b/dev/modules/Flash/Flash.hxx @@ -0,0 +1,21 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#pragma once + +#ifdef __USE_MBCI_FLASH__ + +#include + +/// @brief get sector count. +/// @return drive sector count. +Kernel::SizeT drv_get_sector_count(); + +/// @brief get device size. +/// @return drive size +Kernel::SizeT drv_get_size(); + +#endif // ifdef __USE_MBCI_FLASH__ diff --git a/dev/modules/GLCG/GLCG.hxx b/dev/modules/GLCG/GLCG.hxx new file mode 100644 index 00000000..358e3e45 --- /dev/null +++ b/dev/modules/GLCG/GLCG.hxx @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#pragma once + +#include \ No newline at end of file diff --git a/dev/modules/GPRS/.keepme b/dev/modules/GPRS/.keepme new file mode 100644 index 00000000..e69de29b diff --git a/dev/modules/HPET/.gitkeep b/dev/modules/HPET/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/modules/HPET/Defines.hxx b/dev/modules/HPET/Defines.hxx new file mode 100644 index 00000000..dd288aad --- /dev/null +++ b/dev/modules/HPET/Defines.hxx @@ -0,0 +1,42 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + File: HPET.hxx + Purpose: HPET builtin. + + Revision History: + +------------------------------------------- */ + +#pragma once + +#include +#include + +namespace Kernel +{ + struct PACKED HPETAddressStructure final + { + Kernel::UInt8 AddressSpaceId; // 0 - system memory, 1 - system I/O + Kernel::UInt8 RegisterBitWidth; + Kernel::UInt8 RegisterBitOffset; + Kernel::UInt8 Reserved; + Kernel::UInt64 Address; + }; + + struct PACKED HPETHeader final : public SDT + { + Kernel::UInt8 HardwareRevId; + Kernel::UInt8 ComparatorCount : 5; + Kernel::UInt8 CounterSize : 1; + Kernel::UInt8 Reserved : 1; + Kernel::UInt8 LegacyReplacement : 1; + Kernel::UInt16 PciVendorId; + HPETAddressStructure Address; + Kernel::UInt8 HpetNumber; + Kernel::UInt16 MinimumTick; + Kernel::UInt8 PageProtection; + }; + +} // namespace Kernel diff --git a/dev/modules/IEEE802/.gitkeep b/dev/modules/IEEE802/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/modules/LTE/.keepme b/dev/modules/LTE/.keepme new file mode 100644 index 00000000..e69de29b diff --git a/dev/modules/LTE/IO.hxx b/dev/modules/LTE/IO.hxx new file mode 100644 index 00000000..15546515 --- /dev/null +++ b/dev/modules/LTE/IO.hxx @@ -0,0 +1,28 @@ +/* ------------------------------------------- + +Copyright ZKA Technologies.. + +File: LTE\IO.hxx. +Purpose: LTE I/O. + +------------------------------------------- */ + +#ifndef _INC_NETWORK_LTE_IO_HXX_ +#define _INC_NETWORK_LTE_IO_HXX_ + +#include +#include + +/// @brief Long Term Evolution I/O routines. + +/// @brief Turn on SIM slot. +Kernel::Boolean lte_turn_on_slot(Kernel::Int32 slot); + +/// @brief Turn off SIM slot. +Kernel::Boolean lte_turn_off_slot(Kernel::Int32 slot); + +/// @brief Send AT command. +Kernel::Boolean lte_send_at_command(Kernel::Char* buf, + Kernel::Size bufSz); + +#endif // ifndef _INC_NETWORK_LTE_IO_HXX_ diff --git a/dev/modules/MBCI/Interface.hxx b/dev/modules/MBCI/Interface.hxx new file mode 100644 index 00000000..e895b3f2 --- /dev/null +++ b/dev/modules/MBCI/Interface.hxx @@ -0,0 +1,10 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#pragma once + +#include +#include diff --git a/dev/modules/MBCI/MBCI.hxx b/dev/modules/MBCI/MBCI.hxx new file mode 100644 index 00000000..cc525a77 --- /dev/null +++ b/dev/modules/MBCI/MBCI.hxx @@ -0,0 +1,99 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#ifndef _INC_MODULE_MBCI_HXX_ +#define _INC_MODULE_MBCI_HXX_ + +#include +#include + +/** +- VCC (IN) (OUT for MCU) +- CLK (IN) (OUT for MCU) +- ACK (BI) (Contains an Acknowledge Packet Frame) +- D0- (IN) (Starts with the Host Interface Packet Frame) +- D1- (IN) (Starts with the Host Interface Packet Frame) +- D0+ (OUT) (Starts with the Host Interface Packet Frame) +- D1+ (OUT) (Starts with the Host Interface Packet Frame) +- GND (IN) (OUT for MCU) + */ + +#define cMBCIZeroSz (8) +#define cMBCIMagic "MBCI " + +namespace Kernel +{ + struct IMBCIHost; + struct IMBCIHostPacketFrame; + + /// @brief MBCI Packet frame header + struct PACKED IMBCIHostPacketFrame final + { + UInt32 Magic; + UInt32 HostId; + UInt32 Flags; + UInt32 VendorId; + UInt32 DeviceId; + UInt32 DeviceSpeed; + Bool Acknowledge; + Char Zero[cMBCIZeroSz]; + }; + + enum + { + eMBCISpeedDeviceInvalid, + eMBCILowSpeedDevice, + eMBCIHighSpeedDevice, + eMBCISpeedDeviceCount, + }; + + /// @brief MBCI Host Interface header. + struct PACKED IMBCIHost final + { + UInt32 Magic; + UInt32 HostId; + UInt16 VendorId; + UInt16 DeviceId; + UInt8 MemoryType; + UInt16 HostType; + UInt16 HostFlags; + UInt8 Error; + UInt8 Status; + UInt8 InterruptEnable; + UInt64 BaseAddressRegister; + UInt64 BaseAddressRegisterSize; + Char Zero[cMBCIZeroSz]; + }; + + /// @brief MBCI host flags. + enum MBCIHostFlags + { + eMBCIHostFlagsSupportsNothing, // Invalid MBCI device. + eMBCIHostFlagsSupportsAPM, // Advanced Power Management. + eMBCIHostFlagsSupportsDaisyChain, // Is daisy chained. + eMBCIHostFlagsSupportsHWInterrupts, // Has HW interrupts. + eMBCIHostFlagsSupportsDMA, // Has DMA. + eMBCIHostFlagsExtended = __UINT16_MAX__, // Extended flags table. + }; + + enum MBCIHostKind + { + eMBCIHostKindHardDisk, + eMBCIHostKindOpticalDisk, + eMBCIHostKindKeyboardLow, + eMBCIHostKindMouseLow, + eMBCIHostKindMouseHigh, + eMBCIHostKindKeyboardHigh, + eMBCIHostKindNetworkInterface, + eMBCIHostKindDaisyChain, + eMBCIHostKindStartExtended = __UINT16_MAX__, // Extended vendor table. + }; + + /// @brief An AuthKey is a context used to decrpy data from an MBCI packet. + typedef UInt64 MBCIAuthyKeyType; +} // namespace Kernel + +#endif // ifndef _INC_MODULE_MBCI_HXX_ diff --git a/dev/modules/NVME/.gitkeep b/dev/modules/NVME/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/modules/NVME/NVME.hxx b/dev/modules/NVME/NVME.hxx new file mode 100644 index 00000000..3667b980 --- /dev/null +++ b/dev/modules/NVME/NVME.hxx @@ -0,0 +1,112 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + Revision History: + + ??/??/24: Added file (amlel) + 23 Jul 24: Update filename to Defines.hxx and using ALIGN_NVME for NVME structs. (amlel) + +------------------------------------------- */ + +#ifndef __MODULE_NVME_HXX__ +#define __MODULE_NVME_HXX__ + +#include + +/// TODO: checklist in: https://wiki.osdev.org/NVMe + +#define ALIGN_NVME ATTRIBUTE(aligned(sizeof(Kernel::NVMEInt32))) + +namespace Kernel +{ + typedef UInt32 NVMEInt32; + + struct ALIGN_NVME NVMEBar0 final + { + NVMEInt32 fCapabilities; + NVMEInt32 fVersion; + NVMEInt32 fIntMaskSet; + NVMEInt32 fIntMaskClr; + NVMEInt32 fContrlConf; + NVMEInt32 fContrlStat; + NVMEInt32 fAdminQueueAttr; + NVMEInt32 fAdminSubmissionQueue; + NVMEInt32 fAdminCompletionQueue; + }; + + struct ALIGN_NVME NVMEQueue final + { + NVMEInt32 fOpcode; + NVMEInt32 fNSID; + NVMEInt32 fReserved[3]; + NVMEInt32 fMetadataPtr[5]; + NVMEInt32 fDataPtr[9]; + NVMEInt32 CommandSpecific[15]; + }; + + enum + { + eCreateCompletionQueueNVME = 0x05, + eCreateSubmissionQueueNVME = 0x01, + eIdentifyNVME = 0x06, + eReadNVME = 0x02, + eWriteNVME = 0x01, + }; + + template + inline Bool nvme_create_admin_command(NVMEQueue* entry, UInt32 nsid, UInt32 prpTransfer[3], UInt32 startingLba[2], UInt32 lowTransferBlocks) + { + if (entry == nullptr) + return false; + + entry->CommandSpecific[9] = startingLba[0]; + entry->CommandSpecific[10] = startingLba[1]; + + entry->CommandSpecific[11] = lowTransferBlocks; + + entry->CommandSpecific[5] = prpTransfer[0]; + entry->CommandSpecific[6] = prpTransfer[1]; + entry->CommandSpecific[7] = prpTransfer[2]; + + entry->CommandSpecific[0] = nsid; + + return true; + } + + template + inline Bool nvme_create_io_command(NVMEQueue* entry, UInt64 baseAddress, UInt32 identLoAndQueueSizeHi, UInt32 flagsLoAndQueueComplIdHi, UInt32 identify, Bool provideIdentify = false, Bool namespaceIdentify = false) + { + if (entry == nullptr) + return false; + + if (baseAddress == 0) + return false; + + entry->fOpcode = Opcode; + + entry->CommandSpecific[5] = (baseAddress & 0xFF); + entry->CommandSpecific[6] = static_cast(baseAddress); + + if (!provideIdentify) + { + entry->CommandSpecific[9] = identLoAndQueueSizeHi; + entry->CommandSpecific[10] = flagsLoAndQueueComplIdHi; + } + else + { + entry->CommandSpecific[9] = identify; + + if (namespaceIdentify) + { + entry->CommandSpecific[0] = 1; + } + } + + // use (1 << 0) as contigunous is better supported. + + return true; + } +} // namespace Kernel + +#endif // ifndef __MODULE_NVME_HXX__ diff --git a/dev/modules/OHCI/.gitkeep b/dev/modules/OHCI/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/modules/ReadMe.md b/dev/modules/ReadMe.md new file mode 100644 index 00000000..cf2e5413 --- /dev/null +++ b/dev/modules/ReadMe.md @@ -0,0 +1,7 @@ +# Kernel Modules. + +## Why? + +They are pluggable modules for builtin hardware support. + +###### Copyright ZKA Technologies. All rights reserved. diff --git a/dev/modules/SCSI/.gitkeep b/dev/modules/SCSI/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/modules/SCSI/SCSI.hxx b/dev/modules/SCSI/SCSI.hxx new file mode 100644 index 00000000..5283bc01 --- /dev/null +++ b/dev/modules/SCSI/SCSI.hxx @@ -0,0 +1,14 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#pragma once + +#include + +/// @file SCSI.hxx +/// @brief Serial SCSI driver. + +typedef Kernel::UInt16 scsi_packet_type[12]; diff --git a/dev/modules/WiFi/.gitkeep b/dev/modules/WiFi/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/modules/XHCI/.gitkeep b/dev/modules/XHCI/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/modules/XHCI/Defines.hxx b/dev/modules/XHCI/Defines.hxx new file mode 100644 index 00000000..b882607c --- /dev/null +++ b/dev/modules/XHCI/Defines.hxx @@ -0,0 +1,70 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + File: Defines.hxx + Purpose: XHCI (and backwards) header. + + Revision History: + + 01/02/24: Added file (amlel) + 03/02/24: Update filename to Defines.hxx (amlel) + +------------------------------------------- */ + +#pragma once + +#include + +using namespace Kernel; + +#define kUSBCommand (UInt16)0x0 +#define kUSBStatus (UInt16)0x2 +#define kUSBInterruptEnable (UInt16)0x4 +#define kUSBFrameNum (UInt16)0x6 +#define kUSBFrameListBaseAddress (UInt16)0x8 +#define kUSBFrameModifyStart (UInt16)0xC +#define kUSBPort1StatusCtrl (UInt16)0x10 +#define kUSBPort2StatusCtrl (UInt16)0x12 + +typedef struct USBCommandRegister final +{ + UInt8 mReserved[8]; // Reserved + UInt8 + mMaxPacket; // 0 = Max packet size 32 bits 1 = Max packet size 64 bits + UInt8 mConfigure; + UInt8 mSoftwareDebug; + UInt8 mGlobalResume; + UInt8 mGlobalSuspend; + UInt8 mHostCtrlReset; + UInt8 mRun; // 1 = Controller execute frame list entries +} USBCommandRegister; + +typedef struct USBStatusRegister final +{ + UInt8 mReserved[8]; // Reserved + UInt8 mHalted; // 1 = bit 0 in CMD is zero 0 = bit 0 in CMD is 1 + UInt8 mProcessError; + UInt8 mSystemError; + UInt8 mResumeDetected; + UInt8 mErrorInterrupt; + UInt8 mInterrupt; +} USBStatusRegister; + +typedef struct USBInterruptEnableRegister final +{ + UInt8 mReserved[4]; // Reserved + UInt8 mShortPacket; // 1=Enable interrupt 0=Disable interrupt + UInt8 mComplete; // 1=Enable interrupt 0=Disable interrupt + UInt8 mResume; // 1=Enable interrupt 0=Disable interrupt + UInt8 mTimeoutCRC; // 1=Enable interrupt 0=Disable interrupt +} USBInterruptEnableRegister; + +/* + Some terminology: + + Frame Number: Number of processed entry of the Frame List. + Frame List Base Address: + 32-bit physical adress of Frame List. Remember that first 12 bytes are + always 0. The Frame List must contain 1024 entries. +*/ diff --git a/dev/prm/pdf.hxx b/dev/prm/pdf.hxx index 24d5be01..65bc50bf 100644 --- a/dev/prm/pdf.hxx +++ b/dev/prm/pdf.hxx @@ -47,4 +47,4 @@ namespace Kernel::PDF virtual SizeT GetPageCount() = 0; }; -} // namespace CG::PDF +} // namespace Kernel::PDF diff --git a/dev/sci/sci_base.hxx b/dev/sci/sci_base.hxx index 7638ca1a..9f627f19 100644 --- a/dev/sci/sci_base.hxx +++ b/dev/sci/sci_base.hxx @@ -39,13 +39,13 @@ typedef void* VoidPtr; typedef __UINTPTR_TYPE__ UIntPtr; typedef char Char; -#include +#include #ifdef __SCI_IMPL__ #include #else class IUnknown; // Refrenced from an IDB entry. -class ICLSID; // From the IDB, the constructor of the object, e.g: WordUCLSID. +class ICLSID; // From the IDB, the constructor of the object, e.g: IAppCLSID. class UUID; class ATTRIBUTE(uuid("d7c144b6-0792-44b8-b06b-02b227b547df")) IUnknown @@ -214,6 +214,12 @@ IMPORT_C SInt32 ErrGetLastError(UInt0); IMPORT_C UInt0 ThrExitCurrentThread(_Input SInt32 exit_code); IMPORT_C UInt0 ThrExitMainThread(_Input SInt32 exit_code); +IMPORT_C UInt0 ThrExitThread(_Input ThreadObject thread, _Input SInt32 exit_code); + +typedef Void(*GenericThreadFn)(Void); + +IMPORT_C ThreadObject ThrCreateThread(GenericThreadFn proc); + IMPORT_C UInt0 ThrExitYieldThread(UInt0); IMPORT_C UInt0 ThrExitJoinThread(UInt0); diff --git a/dev/sci/sci_err.hxx b/dev/sci/sci_err.hxx deleted file mode 100644 index a1e56dfd..00000000 --- a/dev/sci/sci_err.hxx +++ /dev/null @@ -1,47 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#pragma once - -#define ErrLocalIsOk() (kLastError == kErrorSuccess) -#define ErrLocalFailed() (kLastError != kErrorSuccess) -#define ErrLocal() (kLastError) - -typedef SInt32 ZKAErr; - -inline constexpr ZKAErr kErrorSuccess = 0; -inline constexpr ZKAErr kErrorExecutable = 33; -inline constexpr ZKAErr kErrorExecutableLib = 34; -inline constexpr ZKAErr kErrorFileNotFound = 35; -inline constexpr ZKAErr kErrorDirectoryNotFound = 36; -inline constexpr ZKAErr kErrorDiskReadOnly = 37; -inline constexpr ZKAErr kErrorDiskIsFull = 38; -inline constexpr ZKAErr kErrorProcessFault = 39; -inline constexpr ZKAErr kErrorSocketHangUp = 40; -inline constexpr ZKAErr kErrorThreadLocalStorage = 41; -inline constexpr ZKAErr kErrorMath = 42; -inline constexpr ZKAErr kErrorNoNetwork = 43; -inline constexpr ZKAErr kErrorHeapOutOfMemory = 44; -inline constexpr ZKAErr kErrorNoSuchDisk = 45; -inline constexpr ZKAErr kErrorFileExists = 46; -inline constexpr ZKAErr kErrorFormatFailed = 47; -inline constexpr ZKAErr kErrorNetworkTimeout = 48; -inline constexpr ZKAErr kErrorInternal = 49; -inline constexpr ZKAErr kErrorForkAlreadyExists = 50; -inline constexpr ZKAErr kErrorOutOfTeamSlot = 51; -inline constexpr ZKAErr kErrorHeapNotPresent = 52; -inline constexpr ZKAErr kErrorNoEntrypoint = 53; -inline constexpr ZKAErr kErrorDiskIsCorrupted = 54; -inline constexpr ZKAErr kErrorDisk = 55; -inline constexpr ZKAErr kErrorInvalidData = 56; -inline constexpr ZKAErr kErrorAsync = 57; -inline constexpr ZKAErr kErrorNonBlocking = 58; -inline constexpr ZKAErr kErrorIPC = 59; -inline constexpr ZKAErr kErrorSign = 60; -inline constexpr ZKAErr kErrorInvalidCreds = 61; -inline constexpr ZKAErr kErrorUnimplemented = 0; - -IMPORT_C ZKAErr kLastError; diff --git a/dev/sci/sci_lpc.hxx b/dev/sci/sci_lpc.hxx new file mode 100644 index 00000000..6b52050b --- /dev/null +++ b/dev/sci/sci_lpc.hxx @@ -0,0 +1,47 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#pragma once + +#define ErrLocalIsOk() (kLastError == kErrorSuccess) +#define ErrLocalFailed() (kLastError != kErrorSuccess) +#define ErrLocal() (kLastError) + +typedef SInt32 ErrObject; + +inline constexpr ErrObject kErrorSuccess = 0; +inline constexpr ErrObject kErrorExecutable = 33; +inline constexpr ErrObject kErrorExecutableLib = 34; +inline constexpr ErrObject kErrorFileNotFound = 35; +inline constexpr ErrObject kErrorDirectoryNotFound = 36; +inline constexpr ErrObject kErrorDiskReadOnly = 37; +inline constexpr ErrObject kErrorDiskIsFull = 38; +inline constexpr ErrObject kErrorProcessFault = 39; +inline constexpr ErrObject kErrorSocketHangUp = 40; +inline constexpr ErrObject kErrorThreadLocalStorage = 41; +inline constexpr ErrObject kErrorMath = 42; +inline constexpr ErrObject kErrorNoNetwork = 43; +inline constexpr ErrObject kErrorHeapOutOfMemory = 44; +inline constexpr ErrObject kErrorNoSuchDisk = 45; +inline constexpr ErrObject kErrorFileExists = 46; +inline constexpr ErrObject kErrorFormatFailed = 47; +inline constexpr ErrObject kErrorNetworkTimeout = 48; +inline constexpr ErrObject kErrorInternal = 49; +inline constexpr ErrObject kErrorForkAlreadyExists = 50; +inline constexpr ErrObject kErrorOutOfTeamSlot = 51; +inline constexpr ErrObject kErrorHeapNotPresent = 52; +inline constexpr ErrObject kErrorNoEntrypoint = 53; +inline constexpr ErrObject kErrorDiskIsCorrupted = 54; +inline constexpr ErrObject kErrorDisk = 55; +inline constexpr ErrObject kErrorInvalidData = 56; +inline constexpr ErrObject kErrorAsync = 57; +inline constexpr ErrObject kErrorNonBlocking = 58; +inline constexpr ErrObject kErrorIPC = 59; +inline constexpr ErrObject kErrorSign = 60; +inline constexpr ErrObject kErrorInvalidCreds = 61; +inline constexpr ErrObject kErrorUnimplemented = 0; + +IMPORT_C ErrObject kLastError; diff --git a/dev/zba/BootKit/BootKit.hxx b/dev/zba/BootKit/BootKit.hxx index 96ded41c..12e595e2 100644 --- a/dev/zba/BootKit/BootKit.hxx +++ b/dev/zba/BootKit/BootKit.hxx @@ -26,7 +26,7 @@ /***********************************************************************************/ #include -#include +#include #include diff --git a/dev/zba/BootKit/Device.hxx b/dev/zba/BootKit/Device.hxx index dd11c78d..b08c8e10 100644 --- a/dev/zba/BootKit/Device.hxx +++ b/dev/zba/BootKit/Device.hxx @@ -6,7 +6,7 @@ #pragma once -#include +#include using namespace Kernel; diff --git a/dev/zba/BootKit/HW/ATA.hxx b/dev/zba/BootKit/HW/ATA.hxx index 14ee7964..67a8aa97 100644 --- a/dev/zba/BootKit/HW/ATA.hxx +++ b/dev/zba/BootKit/HW/ATA.hxx @@ -6,7 +6,7 @@ #pragma once -#include +#include #include using namespace Kernel; diff --git a/dev/zba/BootKit/HW/SATA.hxx b/dev/zba/BootKit/HW/SATA.hxx index 63e40fa1..47dc8f7f 100644 --- a/dev/zba/BootKit/HW/SATA.hxx +++ b/dev/zba/BootKit/HW/SATA.hxx @@ -7,7 +7,7 @@ #pragma once #include -#include +#include class BootDeviceSATA final { diff --git a/dev/zba/amd64-efi.make b/dev/zba/amd64-efi.make index 49008035..69d5ea8a 100644 --- a/dev/zba/amd64-efi.make +++ b/dev/zba/amd64-efi.make @@ -3,10 +3,10 @@ # This is the bootloader makefile. ################################################## -CC_GNU=x86_64-w64-mingw32-g++ -LD_GNU=x86_64-w64-mingw32-ld +CC_GNU=x86_64-w64-mingw32-g++.exe +LD_GNU=x86_64-w64-mingw32-ld.exe -WINDRES=x86_64-w64-mingw32-windres +WINDRES=x86_64-w64-mingw32-windres.exe ADD_FILE=touch COPY=cp @@ -72,8 +72,8 @@ all: compile-amd64 $(COPY) ../zka/$(KERNEL) src/Root/$(KERNEL) $(COPY) ../sci/$(SCI) src/Root/$(SCI) $(COPY) ../ddk/$(DDK) src/Root/$(DDK) - $(COPY) ./Modules/SysChk/$(SYS_CHK) src/Root/$(SYS_CHK) - $(COPY) ./Modules/SysChk/$(SYS_CHK) src/Root/zka/$(STARTUP) + $(COPY) ./modules/SysChk/$(SYS_CHK) src/Root/$(SYS_CHK) + $(COPY) ./modules/SysChk/$(SYS_CHK) src/Root/zka/$(STARTUP) $(COPY) ../crt/$(CRT) src/Root/$(CRT) $(COPY) src/$(BOOT_LOADER) src/Root/$(BOOT_LOADER) diff --git a/dev/zba/src/HEL/AMD64/BootFileReader.cxx b/dev/zba/src/HEL/AMD64/BootFileReader.cxx index 764b10d4..864e96ac 100644 --- a/dev/zba/src/HEL/AMD64/BootFileReader.cxx +++ b/dev/zba/src/HEL/AMD64/BootFileReader.cxx @@ -13,7 +13,7 @@ #include #include #include -#include +#include /// @file BootFileReader /// @brief Bootloader File reader. diff --git a/dev/zba/src/HEL/AMD64/BootMain.cxx b/dev/zba/src/HEL/AMD64/BootMain.cxx index 40c65ae1..7f9c55cf 100644 --- a/dev/zba/src/HEL/AMD64/BootMain.cxx +++ b/dev/zba/src/HEL/AMD64/BootMain.cxx @@ -6,8 +6,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/dev/zba/src/Thread.cxx b/dev/zba/src/Thread.cxx index 2c6fc4b2..b19894a9 100644 --- a/dev/zba/src/Thread.cxx +++ b/dev/zba/src/Thread.cxx @@ -13,7 +13,7 @@ #include #include #include -#include +#include EXTERN_C { diff --git a/dev/zka/FirmwareKit/EFI/API.hxx b/dev/zka/FirmwareKit/EFI/API.hxx index 99cfce94..b742db07 100644 --- a/dev/zka/FirmwareKit/EFI/API.hxx +++ b/dev/zka/FirmwareKit/EFI/API.hxx @@ -21,7 +21,7 @@ class BTextWriter; #define __BOOTKIT_NO_INCLUDE__ 1 #include -#include +#include #endif // ifdef __NEWOSLDR__ inline EfiSystemTable* ST = nullptr; diff --git a/dev/zka/HALKit/AMD64/HalACPIFactoryInterface.cxx b/dev/zka/HALKit/AMD64/HalACPIFactoryInterface.cxx index 1cb8ce07..83f9993f 100644 --- a/dev/zka/HALKit/AMD64/HalACPIFactoryInterface.cxx +++ b/dev/zka/HALKit/AMD64/HalACPIFactoryInterface.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include +#include #include #include #include diff --git a/dev/zka/HALKit/AMD64/HalAPICController.cxx b/dev/zka/HALKit/AMD64/HalAPICController.cxx index 5964c432..2c2c8765 100644 --- a/dev/zka/HALKit/AMD64/HalAPICController.cxx +++ b/dev/zka/HALKit/AMD64/HalAPICController.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include +#include #include #define cIOAPICRegVal (4) diff --git a/dev/zka/HALKit/AMD64/HalCoreMPScheduler.cxx b/dev/zka/HALKit/AMD64/HalCoreMPScheduler.cxx index 18ab835c..ae6dc905 100644 --- a/dev/zka/HALKit/AMD64/HalCoreMPScheduler.cxx +++ b/dev/zka/HALKit/AMD64/HalCoreMPScheduler.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include +#include #include #include #include @@ -12,7 +12,7 @@ #include #include #include -#include +#include // Needed for SMP. // #include diff --git a/dev/zka/HALKit/AMD64/HalKernelMain.cxx b/dev/zka/HALKit/AMD64/HalKernelMain.cxx index 83c51734..30124932 100644 --- a/dev/zka/HALKit/AMD64/HalKernelMain.cxx +++ b/dev/zka/HALKit/AMD64/HalKernelMain.cxx @@ -7,10 +7,10 @@ #include #include #include -#include +#include #include #include -#include +#include namespace Kernel::HAL { diff --git a/dev/zka/HALKit/AMD64/HalTimer.cxx b/dev/zka/HALKit/AMD64/HalTimer.cxx index 4a5d38cf..a87fe0a2 100644 --- a/dev/zka/HALKit/AMD64/HalTimer.cxx +++ b/dev/zka/HALKit/AMD64/HalTimer.cxx @@ -11,7 +11,7 @@ ------------------------------------------- */ -#include +#include #include #include diff --git a/dev/zka/HALKit/AMD64/Storage/AHCI.cxx b/dev/zka/HALKit/AMD64/Storage/AHCI.cxx index 95d73c03..aa701112 100644 --- a/dev/zka/HALKit/AMD64/Storage/AHCI.cxx +++ b/dev/zka/HALKit/AMD64/Storage/AHCI.cxx @@ -15,7 +15,7 @@ * */ -#include +#include #include #ifdef __AHCI__ diff --git a/dev/zka/HALKit/AMD64/Storage/ATA-DMA.cxx b/dev/zka/HALKit/AMD64/Storage/ATA-DMA.cxx index 49d10a7e..9fc5169c 100644 --- a/dev/zka/HALKit/AMD64/Storage/ATA-DMA.cxx +++ b/dev/zka/HALKit/AMD64/Storage/ATA-DMA.cxx @@ -17,7 +17,7 @@ #include -#include +#include #include using namespace Kernel; diff --git a/dev/zka/HALKit/AMD64/Storage/ATA-PIO.cxx b/dev/zka/HALKit/AMD64/Storage/ATA-PIO.cxx index 2d02d89a..f3d0c54b 100644 --- a/dev/zka/HALKit/AMD64/Storage/ATA-PIO.cxx +++ b/dev/zka/HALKit/AMD64/Storage/ATA-PIO.cxx @@ -15,7 +15,7 @@ * */ -#include +#include #include #ifdef __ATA_PIO__ diff --git a/dev/zka/HALKit/ARM64/HalKernelMain.cxx b/dev/zka/HALKit/ARM64/HalKernelMain.cxx index 2a08bb57..56287733 100644 --- a/dev/zka/HALKit/ARM64/HalKernelMain.cxx +++ b/dev/zka/HALKit/ARM64/HalKernelMain.cxx @@ -5,7 +5,7 @@ ------------------------------------------- */ #include -#include +#include #include #include #include @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include diff --git a/dev/zka/Modules/ACPI/.gitkeep b/dev/zka/Modules/ACPI/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/ACPI/ACPI.hxx b/dev/zka/Modules/ACPI/ACPI.hxx deleted file mode 100644 index 00ba4f9e..00000000 --- a/dev/zka/Modules/ACPI/ACPI.hxx +++ /dev/null @@ -1,88 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#ifndef __ACPI__ -#define __ACPI__ - -/** - https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html -*/ - -#include - -namespace Kernel -{ - class PACKED SDT - { - public: - Char Signature[4]; - UInt32 Length; - UInt8 Revision; - Char Checksum; - Char OemId[6]; - Char OemTableId[8]; - UInt32 OemRev; - UInt32 CreatorID; - UInt32 CreatorRevision; - }; - - class PACKED RSDP : public SDT - { - public: - UInt32 RsdtAddress; - UIntPtr XsdtAddress; - UInt8 ExtendedChecksum; - UInt8 Reserved0[3]; - }; - - class PACKED ConfigHeader - { - public: - UInt64 BaseAddress; - UInt16 PciSegGroup; - UInt8 StartBus; - UInt8 EndBus; - UInt32 Reserved; - }; - - enum ACPI_ADDRESS_SPACE_KIND : UInt8 - { - eSystemMemory = 0, - eSystemIO = 1, - ePci = 2, - eController = 3, - eSmBus = 4, - eCount = 5, - eInvalid = 0xFF, - }; - - class PACKED ACPI_ADDRESS final - { - public: - UInt8 AddressSpaceId; - UInt8 RegisterBitWidth; - UInt8 RegisterBitOffset; - UInt8 Reserved; - UIntPtr Address; - }; - - class PACKED RSDT final - { - public: - Char Signature[4]; - UInt32 Length; - UInt8 Revision; - Char Checksum; - Char OemId[6]; - Char OemTableId[8]; - UInt32 OemRev; - UInt32 CreatorID; - UInt32 CreatorRevision; - UInt32 AddressArr[]; - }; -} // namespace Kernel - -#endif // !__ACPI__ diff --git a/dev/zka/Modules/ACPI/ACPIFactoryInterface.hxx b/dev/zka/Modules/ACPI/ACPIFactoryInterface.hxx deleted file mode 100644 index 0d724f3b..00000000 --- a/dev/zka/Modules/ACPI/ACPIFactoryInterface.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#ifndef __MOD_ACPI_HXX__ -#define __MOD_ACPI_HXX__ - -#include -#include -#include -#include -#include - -namespace Kernel -{ - class ACPIFactoryInterface; - - typedef ACPIFactoryInterface PowerFactoryInterface; - - class ACPIFactoryInterface final - { - public: - explicit ACPIFactoryInterface(voidPtr rsdPtr); - ~ACPIFactoryInterface() = default; - - ACPIFactoryInterface& operator=(const ACPIFactoryInterface&) = default; - ACPIFactoryInterface(const ACPIFactoryInterface&) = default; - - public: - Void Shutdown(); // shutdown - Void Reboot(); // soft-reboot - - public: - /// @brief Descriptor find factory. - /// @param signature The signature of the descriptor table (MADT, ACPI...) - /// @return the blob inside an ErrorOr object. - ErrorOr Find(const Char* signature); - - /// @brief Checksum factory. - /// @param checksum the data to checksum - /// @param len it's size - /// @return if it succeed - bool Checksum(const Char* checksum, SSizeT len); // watch for collides! - - public: - ErrorOr operator[](const Char* signature) - { - return this->Find(signature); - } - - private: - VoidPtr fRsdp; // pointer to root descriptor. - SSizeT fEntries; // number of entries, -1 tells that no invalid entries were - // found. - }; -} // namespace Kernel - -#endif // !__MOD_ACPI_HXX__ diff --git a/dev/zka/Modules/AHCI/.gitkeep b/dev/zka/Modules/AHCI/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/AHCI/AHCI.hxx b/dev/zka/Modules/AHCI/AHCI.hxx deleted file mode 100644 index e588ec25..00000000 --- a/dev/zka/Modules/AHCI/AHCI.hxx +++ /dev/null @@ -1,370 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - File: Defines.hxx - Purpose: AHCI header. - - Revision History: - - 03/02/24: Added file (amlel) - -------------------------------------------- */ - -#pragma once - -#include -#include - -// Forward declarations of structs. - -#define kAHCISectorSize (512U) - -struct HbaPort; -struct FisData; -struct FisRegD2H; -struct FisRegH2D; - -/// @brief Frame information type. -enum -{ - kFISTypeRegH2D = 0x27, // Register FIS - host to device - kFISTypeRegD2H = 0x34, // Register FIS - device to host - kFISTypeDMAAct = 0x39, // DMA activate FIS - device to host - kFISTypeDMASetup = 0x41, // DMA setup FIS - bidirectional - kFISTypeData = 0x46, // Data FIS - bidirectional - kFISTypeBIST = 0x58, // BIST activate FIS - bidirectional - kFISTypePIOSetup = 0x5F, // PIO setup FIS - device to host - kFISTypeDevBits = 0xA1, // Set device bits FIS - device to host -}; - -enum -{ - kAHCICmdIdentify = 0xEC, - kAHCICmdReadDma = 0xC8, - kAHCICmdReadDmaEx = 0x25, - kAHCICmdWriteDma = 0xCA, - kAHCICmdWriteDmaEx = 0x35 -}; - -typedef struct FisRegH2D final -{ - // DWORD 0 - Kernel::UInt8 FisType; // FIS_TYPE_REG_H2D - - Kernel::UInt8 PortMul : 4; // Port multiplier - Kernel::UInt8 Reserved0 : 3; // Reserved - Kernel::UInt8 CmdOrCtrl : 1; // 1: Command, 0: Control - - Kernel::UInt8 Command; // Command register - Kernel::UInt8 Featurel; // Feature register, 7:0 - - // DWORD 1 - Kernel::UInt8 Lba0; // LBA low register, 7:0 - Kernel::UInt8 Lba1; // LBA mid register, 15:8 - Kernel::UInt8 Lba2; // LBA high register, 23:16 - Kernel::UInt8 Device; // Device register - - // DWORD 2 - Kernel::UInt8 Lba3; // LBA register, 31:24 - Kernel::UInt8 Lba4; // LBA register, 39:32 - Kernel::UInt8 Lba5; // LBA register, 47:40 - Kernel::UInt8 FeatureHigh; // Feature register, 15:8 - - // DWORD 3 - Kernel::UInt8 CountLow; // Count register, 7:0 - Kernel::UInt8 CountHigh; // Count register, 15:8 - Kernel::UInt8 Icc; // Isochronous command completion - Kernel::UInt8 Control; // Control register - - // DWORD 4 - Kernel::UInt8 Reserved1[4]; // Reserved -} FisRegH2D; - -typedef struct FisRegD2H final -{ - // DWORD 0 - Kernel::UInt8 FisType; // FIS_TYPE_REG_D2H - - Kernel::UInt8 PortMul : 4; // Port multiplier - Kernel::UInt8 Reserved0 : 2; // Reserved - Kernel::UInt8 InterruptBit : 1; // Interrupt bit - Kernel::UInt8 Reserved1 : 1; // Reserved - - Kernel::UInt8 Status; // Status register - Kernel::UInt8 Rrror; // Error register - - // DWORD 1 - Kernel::UInt8 Lba0; // LBA low register, 7:0 - Kernel::UInt8 Lba1; // LBA mid register, 15:8 - Kernel::UInt8 Lba2; // LBA high register, 23:16 - Kernel::UInt8 Device; // Device register - - // DWORD 2 - Kernel::UInt8 Lba3; // LBA register, 31:24 - Kernel::UInt8 Lba4; // LBA register, 39:32 - Kernel::UInt8 Lba5; // LBA register, 47:40 - Kernel::UInt8 Rsv2; // Reserved - - // DWORD 3 - Kernel::UInt8 CountLow; // Count register, 7:0 - Kernel::UInt8 CountHigh; // Count register, 15:8 - Kernel::UInt8 Rsv3[2]; // Reserved - - // DWORD 4 - Kernel::UInt8 Rsv4[4]; // Reserved -} FisRegD2H; - -typedef struct FisData final -{ - // DWORD 0 - Kernel::UInt8 FisType; // FIS_TYPE_DATA - - Kernel::UInt8 PortMul : 4; // Port multiplier - Kernel::UInt8 Reserved0 : 4; // Reserved - - Kernel::UInt8 Reserved1[2]; // Reserved - - // DWORD 1 ~ N - Kernel::UInt32 Data[1]; // Payload -} FisData; - -typedef struct FisPioSetup final -{ - // DWORD 0 - Kernel::UInt8 FisType; // FIS_TYPE_PIO_SETUP - - Kernel::UInt8 PortMul : 4; // Port multiplier - Kernel::UInt8 Reserved0 : 1; // Reserved - Kernel::UInt8 DTD : 1; // Data transfer direction, 1 - device to host - Kernel::UInt8 InterruptBit : 1; // Interrupt bit - Kernel::UInt8 Reserved1 : 1; - - Kernel::UInt8 Status; // Status register - Kernel::UInt8 Error; // Error register - - // DWORD 1 - Kernel::UInt8 Lba0; // LBA low register, 7:0 - Kernel::UInt8 Lba1; // LBA mid register, 15:8 - Kernel::UInt8 Lba2; // LBA high register, 23:16 - Kernel::UInt8 Device; // Device register - - // DWORD 2 - Kernel::UInt8 Lba3; // LBA register, 31:24 - Kernel::UInt8 Lba4; // LBA register, 39:32 - Kernel::UInt8 Lba5; // LBA register, 47:40 - Kernel::UInt8 Rsv2; // Reserved - - // DWORD 3 - Kernel::UInt8 CountLow; // Count register, 7:0 - Kernel::UInt8 CountHigh; // Count register, 15:8 - Kernel::UInt8 Rsv3; // Reserved - Kernel::UInt8 EStatus; // New value of status register - - // DWORD 4 - Kernel::UInt16 TranferCount; // Transfer count - Kernel::UInt8 Rsv4[2]; // Reserved -} FisPioSetup; - -typedef struct FisDmaSetup final -{ - // DWORD 0 - Kernel::UInt8 FisType; // FIS_TYPE_DMA_SETUP - - Kernel::UInt8 PortMul : 4; // Port multiplier - Kernel::UInt8 Reserved0 : 1; // Reserved - Kernel::UInt8 DTD : 1; // Data transfer direction, 1 - device to host - Kernel::UInt8 InterruptBit : 1; // Interrupt bit - Kernel::UInt8 AutoEnable : 1; // Auto-activate. Specifies if DMA Activate FIS is needed - - Kernel::UInt8 Reserved1[2]; // Reserved - - // DWORD 1&2 - 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. - - // DWORD 3 - Kernel::UInt32 Rsvd; // More reserved - - // DWORD 4 - Kernel::UInt32 DmabufOffset; // Byte offset into buffer. First 2 bits must be 0 - - // DWORD 5 - Kernel::UInt32 TransferCount; // Number of bytes to transfer. Bit 0 must be 0 - - // DWORD 6 - Kernel::UInt32 Reserved3; // Reserved -} FisDmaSetup; - -typedef struct FisDevBits final -{ - // DWORD 0 - Kernel::UInt8 FisType; // FIS_TYPE_DMA_SETUP (A1h) - - Kernel::UInt8 Reserved0 : 5; // Reserved - Kernel::UInt8 R0 : 1; - Kernel::UInt8 InterruptBit : 1; - Kernel::UInt8 N : 1; - - Kernel::UInt8 StatusLow : 3; - Kernel::UInt8 R1 : 1; - Kernel::UInt8 StatusHigh : 3; - - Kernel::UInt8 R2 : 1; - Kernel::UInt8 Error; - - // DWORD 1 - Kernel::UInt32 Act; -} FisDevBits; - -/// \brief Enable AHCI device bit in GHC register. -#ifndef kAhciGHC_AE -#define kAhciGHC_AE (31) -#endif //! ifndef kAhciGHC_AE - -typedef struct HbaPort final -{ - Kernel::UInt32 Clb; // 0x00, command list base address, 1K-byte aligned - Kernel::UInt32 Clbu; // 0x04, command list base address upper 32 bits - Kernel::UInt32 Fb; // 0x08, FIS base address, 256-byte aligned - Kernel::UInt32 Fbu; // 0x0C, FIS base address upper 32 bits - Kernel::UInt32 Is; // 0x10, interrupt status - Kernel::UInt32 Ie; // 0x14, interrupt enable - Kernel::UInt32 Cmd; // 0x18, command and status - Kernel::UInt32 Reserved0; // 0x1C, Reserved - Kernel::UInt32 Tfd; // 0x20, task file data - Kernel::UInt32 Sig; // 0x24, signature - Kernel::UInt32 Ssts; // 0x28, SATA status (SCR0:SStatus) - Kernel::UInt32 Sctl; // 0x2C, SATA control (SCR2:SControl) - 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 Fbs; // 0x40, FIS-based switch control - Kernel::UInt32 Reserved1[11]; // 0x44 ~ 0x6F, Reserved - Kernel::UInt32 Vendor[4]; // 0x70 ~ 0x7F, vendor specific -} HbaPort; - -typedef struct HbaMem final -{ - // 0x00 - 0x2B, Generic Host Control - Kernel::UInt32 Cap; // 0x00, Host capability - Kernel::UInt32 Ghc; // 0x04, Global host control - Kernel::UInt32 Is; // 0x08, Interrupt status - Kernel::UInt32 Pi; // 0x0C, Port implemented - Kernel::UInt32 Vs; // 0x10, Version - Kernel::UInt32 Ccc_ctl; // 0x14, Command completion coalescing control - Kernel::UInt32 Ccc_pts; // 0x18, Command completion coalescing ports - Kernel::UInt32 Em_loc; // 0x1C, Enclosure management location - Kernel::UInt32 Em_ctl; // 0x20, Enclosure management control - Kernel::UInt32 Cap2; // 0x24, Host capabilities extended - Kernel::UInt32 Bohc; // 0x28, BIOS/OS handoff control and status - - Kernel::UInt16 Resv0; - Kernel::UInt32 Resv2; - - HbaPort Ports[1]; // 1 ~ 32, 32 is the max ahci devices per controller. -} HbaMem; - -typedef struct HbaCmdHeader final -{ - // DW0 - Kernel::UInt8 Cfl : 5; // Command FIS length in DWORDS, 2 ~ 16 - Kernel::UInt8 Atapi : 1; // ATAPI - Kernel::UInt8 Write : 1; // Write, 1: H2D, 0: D2H - Kernel::UInt8 Prefetchable : 1; // Prefetchable - - Kernel::UInt8 Reset : 1; // Reset - Kernel::UInt8 BIST : 1; // BIST - Kernel::UInt8 Clear : 1; // Clear busy upon R_OK - Kernel::UInt8 Reserved0 : 1; // Reserved - Kernel::UInt8 Pmp : 4; // Port multiplier port - - Kernel::UInt16 Prdtl; // Physical region descriptor table length in entries - volatile Kernel::UInt32 Prdbc; // Physical region descriptor byte count transferred - - Kernel::UInt32 Ctba; // Command table descriptor base address - Kernel::UInt32 Ctbau; // Command table descriptor base address upper 32 bits - - Kernel::UInt32 Reserved1[4]; // Reserved -} HbaCmdHeader; - -typedef struct HbaFis final -{ - // 0x00 - FisDmaSetup Dsfis; // DMA Setup FIS - Kernel::UInt8 Pad0[4]; - // 0x20 - FisPioSetup Psfis; // PIO Setup FIS - Kernel::UInt8 Pad1[12]; - // 0x40 - FisRegD2H Rfis; // Register – Device to Host FIS - Kernel::UInt8 Pad2[4]; - // 0x58 - FisDevBits Sdbfis; // Set Device Bit FIS - // 0x60 - Kernel::UInt8 Ufis[64]; - // 0xA0 - Kernel::UInt8 Rsv[0x100 - 0xA0]; -} HbaFis; - -typedef struct HbaPrdtEntry final -{ - Kernel::UInt32 Dba; // Data base address - Kernel::UInt32 Dbau; // Data base address upper 32 bits - Kernel::UInt32 Reserved0; // Reserved - // DW3 - Kernel::UInt32 Dbc : 22; // Byte count, 4M max - Kernel::UInt32 Reserved1 : 9; // Reserved - Kernel::UInt32 InterruptBit : 1; // Interrupt on completion -} HbaPrdtEntry; - -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 prdtEntries[1]; // Physical region descriptor table entries, 0 ~ 65535 -} HbaCmdTbl; - -/* EOF */ - -#if defined(__AHCI__) - -/// @brief Initializes an AHCI disk. -/// @param PortsImplemented the amount of port that have been detected. -/// @return -Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented); - -Kernel::Boolean drv_std_detected(Kernel::Void); - -/// @brief Read from disk. -/// @param Lba -/// @param Buf -/// @param SectorSz -/// @param Size -/// @return -Kernel::Void drv_std_read(Kernel::UInt64 Lba, Kernel::Char* Buf, Kernel::SizeT SectorSz, Kernel::SizeT Size); - -/// @brief Write to disk. -/// @param Lba -/// @param Buf -/// @param SectorSz -/// @param Size -/// @return -Kernel::Void drv_std_write(Kernel::UInt64 Lba, Kernel::Char* Buf, Kernel::SizeT SectorSz, Kernel::SizeT Size); - -/// @brief get sector count. -Kernel::SizeT drv_get_sector_count(); - -/// @brief get device size. -Kernel::SizeT drv_get_size(); - -/// @brief get sector count. -Kernel::SizeT drv_get_sector_count(); - -/// @brief get device size. -Kernel::SizeT drv_get_size(); - -#endif // ifdef __NEWOSKRNL__ diff --git a/dev/zka/Modules/APM/.gitkeep b/dev/zka/Modules/APM/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/ATA/ATA.hxx b/dev/zka/Modules/ATA/ATA.hxx deleted file mode 100644 index f550ddc6..00000000 --- a/dev/zka/Modules/ATA/ATA.hxx +++ /dev/null @@ -1,156 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - File: Defines.hxx - Purpose: ATA header. - - Revision History: - - 03/02/24: Added file (amlel) - -------------------------------------------- */ - -#pragma once - -#ifndef __AHCI__ - -#include -#include - -///! Status register -#define ATA_SR_BSY 0x80 -#define ATA_SR_DRDY 0x40 -#define ATA_SR_DF 0x20 -#define ATA_SR_DSC 0x10 -#define ATA_SR_DRQ 0x08 -#define ATA_SR_CORR 0x04 -#define ATA_SR_IDX 0x02 -#define ATA_SR_ERR 0x01 - -///! Error register -#define ATA_ER_BBK 0x80 -#define ATA_ER_UNC 0x40 -#define ATA_ER_MC 0x20 -#define ATA_ER_IDNF 0x10 -#define ATA_ER_MCR 0x08 -#define ATA_ER_ABRT 0x04 -#define ATA_ER_TK0NF 0x02 -#define ATA_ER_AMNF 0x01 - -#define ATA_CMD_READ_PIO 0x20 -#define ATA_CMD_READ_PIO_EXT 0x24 -#define ATA_CMD_READ_DMA 0xC8 -#define ATA_CMD_READ_DMA_EXT 0x25 -#define ATA_CMD_WRITE_PIO 0x30 -#define ATA_CMD_WRITE_PIO_EXT 0x34 -#define ATA_CMD_WRITE_DMA 0xCA -#define ATA_CMD_WRITE_DMA_EXT 0x35 -#define ATA_CMD_CACHE_FLUSH 0xE7 -#define ATA_CMD_CACHE_FLUSH_EXT 0xEA -#define ATA_CMD_PACKET 0xA0 -#define ATA_CMD_IDENTIFY_PACKET 0xA1 -#define ATA_CMD_IDENTIFY 0xEC - -///! ident offsets, use with data that we got from ATA_CMD_IDENTIFY. -#define ATA_IDENT_DEVICE_TYPE 0 -#define ATA_IDENT_CYLINDERS 2 -#define ATA_IDENT_HEADS 6 -#define ATA_IDENT_SECTORS 12 -#define ATA_IDENT_SERIAL 20 -#define ATA_IDENT_MODEL 54 -#define ATA_IDENT_CAPABILITIES 98 -#define ATA_IDENT_FIELDVALID 106 -#define ATA_IDENT_MAX_LBA 120 -#define ATA_IDENT_COMMANDSETS 164 -#define ATA_IDENT_MAX_LBA_EXT 200 - -#define ATA_MASTER 0x00 -#define ATA_SLAVE 0x01 - -///! Register -#define ATA_REG_DATA 0x00 -#define ATA_REG_ERROR 0x01 -#define ATA_REG_FEATURES 0x01 -#define ATA_REG_SEC_COUNT0 0x02 -#define ATA_REG_LBA0 0x03 -#define ATA_REG_LBA1 0x04 -#define ATA_REG_LBA2 0x05 -#define ATA_REG_HDDEVSEL 0x06 -#define ATA_REG_COMMAND 0x07 -#define ATA_REG_STATUS 0x07 -#define ATA_REG_SEC_COUNT1 0x08 -#define ATA_REG_LBA3 0x09 -#define ATA_REG_LBA4 0x0A -#define ATA_REG_LBA5 0x0B -#define ATA_REG_CONTROL 0x0C -#define ATA_REG_ALT_STATUS 0x0C -#define ATA_REG_DEV_ADDRESS 0x0D - -#define ATA_REG_NEIN 0x01 - -#define ATA_PRIMARY_IO 0x1F0 -#define ATA_SECONDARY_IO 0x170 -#define ATA_PRIMARY_DCR_AS 0x3F6 -#define ATA_SECONDARY_DCR_AS 0x376 - -///! Irq -#define ATA_PRIMARY_IRQ 14 -#define ATA_SECONDARY_IRQ 15 - -///! Channels -#define ATA_PRIMARY 0x00 -#define ATA_SECONDARY 0x01 - -#define ATA_CYL_LOW 3 -#define ATA_CYL_MID 4 -#define ATA_CYL_HIGH 5 - -///! IO Direction -#define ATA_READ 0x00 -#define ATA_WRITE 0x013 - -#define ATA_PRIMARY_SEL 0xA0 -#define ATA_SECONDARY_SEL 0xB0 - -///! ATA address register. -#define ATA_ADDRESS1(x) (x + 3) -#define ATA_ADDRESS2(x) (x + 4) -#define ATA_ADDRESS3(x) (x + 5) - -///! ATA command register. -#define ATA_COMMAND(x) (x + 7) - -#define kATASectorSize (512U) - -enum -{ - kATADevicePATA, - kATADeviceSATA, - kATADevicePATA_PI, - kATADeviceSATA_PI, - kATADeviceCount, -}; - -#if defined(__ATA_PIO__) || defined(__ATA_DMA__) - -Kernel::Boolean drv_std_init(Kernel::UInt16 Bus, Kernel::UInt8 Drive, Kernel::UInt16& OutBus, Kernel::UInt8& OutMaster); - -Kernel::Boolean drv_std_detected(Kernel::Void); - -Kernel::Void drv_std_select(Kernel::UInt16 Bus); - -Kernel::Boolean drv_std_wait_io(Kernel::UInt16 IO); - -Kernel::Void drv_std_read(Kernel::UInt64 Lba, Kernel::UInt16 IO, Kernel::UInt8 Master, Kernel::Char* Buf, Kernel::SizeT SectorSz, Kernel::SizeT Size); - -Kernel::Void drv_std_write(Kernel::UInt64 Lba, Kernel::UInt16 IO, Kernel::UInt8 Master, Kernel::Char* Buf, Kernel::SizeT SectorSz, Kernel::SizeT Size); - -/// @brief get sector count. -Kernel::SizeT drv_get_sector_count(); - -/// @brief get device size. -Kernel::SizeT drv_get_size(); - -#endif // ifdef __NEWOSKRNL__ -#endif // ifndef __ATA_PIO__ || __AHCI__ diff --git a/dev/zka/Modules/FB/FB.hxx b/dev/zka/Modules/FB/FB.hxx deleted file mode 100644 index a98eeafe..00000000 --- a/dev/zka/Modules/FB/FB.hxx +++ /dev/null @@ -1,154 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#pragma once - -#include - -#define CGInit() Kernel::SizeT __CG_CURSOR = 0 - -#define CGColor(R, G, B) RGB(R, G, B) - -#define cCGClearClr CGColor(0x0, 0x0, 0x0) - -#define CGFini() __CG_CURSOR = 0 - -/// @brief Performs OR drawing on the framebuffer. -#define CGDrawBitMapInRegionA(_BitMp, _Height, _Width, _BaseX, _BaseY) \ - __CG_CURSOR = 0; \ - \ - for (Kernel::SizeT i = _BaseX; i < (_Height + _BaseX); ++i) \ - { \ - for (Kernel::SizeT u = _BaseY; u < (_Width + _BaseY); ++u) \ - { \ - *(((Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ - 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ - i + \ - 4 * u))) |= (_BitMp)[__CG_CURSOR]; \ - \ - ++__CG_CURSOR; \ - } \ - } - -/// @brief Draws a resource. -#define CGDrawBitMapInRegion(_BitMp, _Height, _Width, _BaseX, _BaseY) \ - __CG_CURSOR = 0; \ - \ - for (Kernel::SizeT i = _BaseX; i < (_Height + _BaseX); ++i) \ - { \ - for (Kernel::SizeT u = _BaseY; u < (_Width + _BaseY); ++u) \ - { \ - *(((Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ - 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ - i + \ - 4 * u))) = (_BitMp)[__CG_CURSOR]; \ - \ - ++__CG_CURSOR; \ - } \ - } - -#define CGDrawBitMapInRegionToRgn(_Rgn, _BitMp, _Height, _Width, _BaseX, _BaseY) \ - __CG_CURSOR = 0; \ - \ - for (Kernel::SizeT i = _BaseX; i < (_Height + _BaseX); ++i) \ - { \ - for (Kernel::SizeT u = _BaseY; u < (_Width + _BaseY); ++u) \ - { \ - *(((Kernel::UInt32*)(_Rgn + \ - 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ - i + \ - 4 * u))) = (_BitMp)[__CG_CURSOR]; \ - \ - ++__CG_CURSOR; \ - } \ - } - -/// @brief Cleans a resource. -#define CGClearRegion(_Height, _Width, _BaseX, _BaseY) \ - \ - for (Kernel::SizeT i = _BaseX; i < _Height + _BaseX; ++i) \ - { \ - for (Kernel::SizeT u = _BaseY; u < _Width + _BaseY; ++u) \ - { \ - *(((volatile Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ - 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ - i + \ - 4 * u))) = cCGClearClr; \ - } \ - } - -/// @brief Draws inside a zone. -#define CGDrawInRegion(_Clr, _Height, _Width, _BaseX, _BaseY) \ - \ - for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ - { \ - for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \ - { \ - *(((volatile Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ - 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ - x_base + \ - 4 * y_base))) = _Clr; \ - } \ - } - -/// @brief Draws inside a zone. -#define CGDrawInRegionToRgn(_Rgn, _Clr, _Height, _Width, _BaseX, _BaseY) \ - __CG_CURSOR = 0; \ - \ - for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ - { \ - for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \ - { \ - *(((volatile Kernel::UInt32*)(_Rgn + \ - 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ - x_base + \ - 4 * y_base))) = _Clr[__CG_CURSOR]; \ - ++__CG_CURSOR; \ - } \ - } - -#define CGDrawInRegionToVideoRgn(_VideoRgn, _Clr, _Height, _Width, _BaseX, _BaseY) \ - __CG_CURSOR = 0; \ - \ - for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ - { \ - for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \ - { \ - *(((volatile Kernel::UInt32*)(_VideoRgn + \ - 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ - x_base + \ - 4 * y_base))) = _Clr; \ - ++__CG_CURSOR; \ - } \ - } - -#define CGDrawInRegionToVideoRgnA(_VideoRgn, _Clr, _Height, _Width, _BaseX, _BaseY) \ - __CG_CURSOR = 0; \ - \ - for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ - { \ - for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \ - { \ - *(((volatile Kernel::UInt32*)(_VideoRgn + \ - 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ - x_base + \ - 4 * y_base))) |= _Clr; \ - ++__CG_CURSOR; \ - } \ - } - -#define CGDrawInRegionA(_Clr, _Height, _Width, _BaseX, _BaseY) \ - \ - for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ - { \ - for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \ - { \ - *(((volatile Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ - 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ - x_base + \ - 4 * y_base))) |= _Clr; \ - } \ - } diff --git a/dev/zka/Modules/FB/Text.hxx b/dev/zka/Modules/FB/Text.hxx deleted file mode 100644 index c225d222..00000000 --- a/dev/zka/Modules/FB/Text.hxx +++ /dev/null @@ -1,178 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#pragma once - -#include -#include - -#define FONT_SIZE_X 8 -#define FONT_SIZE_Y 8 -#define FONT_NOF_CHARS 128 - -inline const Kernel::UInt8 cFontBitmap[FONT_NOF_CHARS][FONT_SIZE_X] = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul) - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019 - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space) - {0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!) - {0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (") - {0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#) - {0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($) - {0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%) - {0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&) - {0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (') - {0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (() - {0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ()) - {0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*) - {0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+) - {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,) - {0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-) - {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.) - {0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/) - {0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0) - {0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1) - {0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2) - {0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3) - {0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4) - {0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5) - {0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6) - {0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7) - {0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8) - {0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9) - {0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:) - {0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (;) - {0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<) - {0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=) - {0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>) - {0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?) - {0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@) - {0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A) - {0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B) - {0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C) - {0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D) - {0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E) - {0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F) - {0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G) - {0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H) - {0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I) - {0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J) - {0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K) - {0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L) - {0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M) - {0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N) - {0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O) - {0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P) - {0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q) - {0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R) - {0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S) - {0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T) - {0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U) - {0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V) - {0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W) - {0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X) - {0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y) - {0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z) - {0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([) - {0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\) - {0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (]) - {0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^) - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_) - {0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`) - {0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a) - {0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b) - {0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c) - {0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d) - {0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e) - {0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f) - {0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g) - {0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h) - {0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i) - {0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j) - {0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k) - {0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l) - {0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m) - {0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n) - {0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o) - {0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p) - {0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q) - {0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r) - {0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s) - {0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t) - {0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u) - {0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v) - {0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w) - {0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x) - {0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y) - {0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z) - {0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({) - {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|) - {0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (}) - {0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~) - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // U+007F - -}; - -inline Kernel::Void CGRenderStringFromBitMap(const Kernel::UInt8* bitmap, const Kernel::SizeT& x_sz, const Kernel::SizeT& y_sz, Kernel::Int32& x_dst, Kernel::Int32& y_dst, Kernel::Int32& color) -{ - Kernel::Int32 x, y; - Kernel::Int32 set; - - x = 0; - y = 0; - set = 0; - - for (; y < y_sz; ++y) - { - for (x = 0; x < x_sz; ++x) - { - set = bitmap[x] & (1 << y); - - if (set) - { - CGDrawInRegion(color, 1, 1, ((x_dst) + x), ((y_dst) + y)); - } - } - } -} - -inline Kernel::Void CGDrawString(const Kernel::Char* text, Kernel::Int32 x_dst, Kernel::Int32 y_dst, Kernel::Int32 color) -{ - for (Kernel::SizeT i = 0; text[i] != 0; ++i) - { - CGRenderStringFromBitMap(&cFontBitmap[text[i]][0], FONT_SIZE_X, FONT_SIZE_Y, x_dst, y_dst, color); - y_dst += FONT_SIZE_Y; - } -} diff --git a/dev/zka/Modules/Flash/Flash.hxx b/dev/zka/Modules/Flash/Flash.hxx deleted file mode 100644 index ccea5a9a..00000000 --- a/dev/zka/Modules/Flash/Flash.hxx +++ /dev/null @@ -1,21 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#pragma once - -#ifdef __USE_MBCI_FLASH__ - -#include - -/// @brief get sector count. -/// @return drive sector count. -Kernel::SizeT drv_get_sector_count(); - -/// @brief get device size. -/// @return drive size -Kernel::SizeT drv_get_size(); - -#endif // ifdef __USE_MBCI_FLASH__ diff --git a/dev/zka/Modules/GLCG/.keepme b/dev/zka/Modules/GLCG/.keepme deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/GPRS/.keepme b/dev/zka/Modules/GPRS/.keepme deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/HPET/.gitkeep b/dev/zka/Modules/HPET/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/HPET/Defines.hxx b/dev/zka/Modules/HPET/Defines.hxx deleted file mode 100644 index 7b6e4589..00000000 --- a/dev/zka/Modules/HPET/Defines.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - File: HPET.hxx - Purpose: HPET builtin. - - Revision History: - -------------------------------------------- */ - -#pragma once - -#include -#include - -namespace Kernel -{ - struct PACKED HPETAddressStructure final - { - Kernel::UInt8 AddressSpaceId; // 0 - system memory, 1 - system I/O - Kernel::UInt8 RegisterBitWidth; - Kernel::UInt8 RegisterBitOffset; - Kernel::UInt8 Reserved; - Kernel::UInt64 Address; - }; - - struct PACKED HPETHeader final : public SDT - { - Kernel::UInt8 HardwareRevId; - Kernel::UInt8 ComparatorCount : 5; - Kernel::UInt8 CounterSize : 1; - Kernel::UInt8 Reserved : 1; - Kernel::UInt8 LegacyReplacement : 1; - Kernel::UInt16 PciVendorId; - HPETAddressStructure Address; - Kernel::UInt8 HpetNumber; - Kernel::UInt16 MinimumTick; - Kernel::UInt8 PageProtection; - }; - -} // namespace Kernel diff --git a/dev/zka/Modules/IEEE802/.gitkeep b/dev/zka/Modules/IEEE802/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/LTE/.keepme b/dev/zka/Modules/LTE/.keepme deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/LTE/IO.hxx b/dev/zka/Modules/LTE/IO.hxx deleted file mode 100644 index 15546515..00000000 --- a/dev/zka/Modules/LTE/IO.hxx +++ /dev/null @@ -1,28 +0,0 @@ -/* ------------------------------------------- - -Copyright ZKA Technologies.. - -File: LTE\IO.hxx. -Purpose: LTE I/O. - -------------------------------------------- */ - -#ifndef _INC_NETWORK_LTE_IO_HXX_ -#define _INC_NETWORK_LTE_IO_HXX_ - -#include -#include - -/// @brief Long Term Evolution I/O routines. - -/// @brief Turn on SIM slot. -Kernel::Boolean lte_turn_on_slot(Kernel::Int32 slot); - -/// @brief Turn off SIM slot. -Kernel::Boolean lte_turn_off_slot(Kernel::Int32 slot); - -/// @brief Send AT command. -Kernel::Boolean lte_send_at_command(Kernel::Char* buf, - Kernel::Size bufSz); - -#endif // ifndef _INC_NETWORK_LTE_IO_HXX_ diff --git a/dev/zka/Modules/MBCI/Interface.hxx b/dev/zka/Modules/MBCI/Interface.hxx deleted file mode 100644 index b3d5debb..00000000 --- a/dev/zka/Modules/MBCI/Interface.hxx +++ /dev/null @@ -1,10 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#pragma once - -#include -#include diff --git a/dev/zka/Modules/MBCI/MBCI.hxx b/dev/zka/Modules/MBCI/MBCI.hxx deleted file mode 100644 index 8f6a7f01..00000000 --- a/dev/zka/Modules/MBCI/MBCI.hxx +++ /dev/null @@ -1,99 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#ifndef _INC_MODULE_MBCI_HXX_ -#define _INC_MODULE_MBCI_HXX_ - -#include -#include - -/** -- VCC (IN) (OUT for MCU) -- CLK (IN) (OUT for MCU) -- ACK (BI) (Contains an Acknowledge Packet Frame) -- D0- (IN) (Starts with the Host Interface Packet Frame) -- D1- (IN) (Starts with the Host Interface Packet Frame) -- D0+ (OUT) (Starts with the Host Interface Packet Frame) -- D1+ (OUT) (Starts with the Host Interface Packet Frame) -- GND (IN) (OUT for MCU) - */ - -#define cMBCIZeroSz (8) -#define cMBCIMagic "MBCI " - -namespace Kernel -{ - struct IMBCIHost; - struct IMBCIHostPacketFrame; - - /// @brief MBCI Packet frame header - struct PACKED IMBCIHostPacketFrame final - { - UInt32 Magic; - UInt32 HostId; - UInt32 Flags; - UInt32 VendorId; - UInt32 DeviceId; - UInt32 DeviceSpeed; - Bool Acknowledge; - Char Zero[cMBCIZeroSz]; - }; - - enum - { - eMBCISpeedDeviceInvalid, - eMBCILowSpeedDevice, - eMBCIHighSpeedDevice, - eMBCISpeedDeviceCount, - }; - - /// @brief MBCI Host Interface header. - struct PACKED IMBCIHost final - { - UInt32 Magic; - UInt32 HostId; - UInt16 VendorId; - UInt16 DeviceId; - UInt8 MemoryType; - UInt16 HostType; - UInt16 HostFlags; - UInt8 Error; - UInt8 Status; - UInt8 InterruptEnable; - UInt64 BaseAddressRegister; - UInt64 BaseAddressRegisterSize; - Char Zero[cMBCIZeroSz]; - }; - - /// @brief MBCI host flags. - enum MBCIHostFlags - { - eMBCIHostFlagsSupportsNothing, // Invalid MBCI device. - eMBCIHostFlagsSupportsAPM, // Advanced Power Management. - eMBCIHostFlagsSupportsDaisyChain, // Is daisy chained. - eMBCIHostFlagsSupportsHWInterrupts, // Has HW interrupts. - eMBCIHostFlagsSupportsDMA, // Has DMA. - eMBCIHostFlagsExtended = __UINT16_MAX__, // Extended flags table. - }; - - enum MBCIHostKind - { - eMBCIHostKindHardDisk, - eMBCIHostKindOpticalDisk, - eMBCIHostKindKeyboardLow, - eMBCIHostKindMouseLow, - eMBCIHostKindMouseHigh, - eMBCIHostKindKeyboardHigh, - eMBCIHostKindNetworkInterface, - eMBCIHostKindDaisyChain, - eMBCIHostKindStartExtended = __UINT16_MAX__, // Extended vendor table. - }; - - /// @brief An AuthKey is a context used to decrpy data from an MBCI packet. - typedef UInt64 MBCIAuthyKeyType; -} // namespace Kernel - -#endif // ifndef _INC_MODULE_MBCI_HXX_ diff --git a/dev/zka/Modules/NVME/.gitkeep b/dev/zka/Modules/NVME/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/NVME/NVME.hxx b/dev/zka/Modules/NVME/NVME.hxx deleted file mode 100644 index 3667b980..00000000 --- a/dev/zka/Modules/NVME/NVME.hxx +++ /dev/null @@ -1,112 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - Revision History: - - ??/??/24: Added file (amlel) - 23 Jul 24: Update filename to Defines.hxx and using ALIGN_NVME for NVME structs. (amlel) - -------------------------------------------- */ - -#ifndef __MODULE_NVME_HXX__ -#define __MODULE_NVME_HXX__ - -#include - -/// TODO: checklist in: https://wiki.osdev.org/NVMe - -#define ALIGN_NVME ATTRIBUTE(aligned(sizeof(Kernel::NVMEInt32))) - -namespace Kernel -{ - typedef UInt32 NVMEInt32; - - struct ALIGN_NVME NVMEBar0 final - { - NVMEInt32 fCapabilities; - NVMEInt32 fVersion; - NVMEInt32 fIntMaskSet; - NVMEInt32 fIntMaskClr; - NVMEInt32 fContrlConf; - NVMEInt32 fContrlStat; - NVMEInt32 fAdminQueueAttr; - NVMEInt32 fAdminSubmissionQueue; - NVMEInt32 fAdminCompletionQueue; - }; - - struct ALIGN_NVME NVMEQueue final - { - NVMEInt32 fOpcode; - NVMEInt32 fNSID; - NVMEInt32 fReserved[3]; - NVMEInt32 fMetadataPtr[5]; - NVMEInt32 fDataPtr[9]; - NVMEInt32 CommandSpecific[15]; - }; - - enum - { - eCreateCompletionQueueNVME = 0x05, - eCreateSubmissionQueueNVME = 0x01, - eIdentifyNVME = 0x06, - eReadNVME = 0x02, - eWriteNVME = 0x01, - }; - - template - inline Bool nvme_create_admin_command(NVMEQueue* entry, UInt32 nsid, UInt32 prpTransfer[3], UInt32 startingLba[2], UInt32 lowTransferBlocks) - { - if (entry == nullptr) - return false; - - entry->CommandSpecific[9] = startingLba[0]; - entry->CommandSpecific[10] = startingLba[1]; - - entry->CommandSpecific[11] = lowTransferBlocks; - - entry->CommandSpecific[5] = prpTransfer[0]; - entry->CommandSpecific[6] = prpTransfer[1]; - entry->CommandSpecific[7] = prpTransfer[2]; - - entry->CommandSpecific[0] = nsid; - - return true; - } - - template - inline Bool nvme_create_io_command(NVMEQueue* entry, UInt64 baseAddress, UInt32 identLoAndQueueSizeHi, UInt32 flagsLoAndQueueComplIdHi, UInt32 identify, Bool provideIdentify = false, Bool namespaceIdentify = false) - { - if (entry == nullptr) - return false; - - if (baseAddress == 0) - return false; - - entry->fOpcode = Opcode; - - entry->CommandSpecific[5] = (baseAddress & 0xFF); - entry->CommandSpecific[6] = static_cast(baseAddress); - - if (!provideIdentify) - { - entry->CommandSpecific[9] = identLoAndQueueSizeHi; - entry->CommandSpecific[10] = flagsLoAndQueueComplIdHi; - } - else - { - entry->CommandSpecific[9] = identify; - - if (namespaceIdentify) - { - entry->CommandSpecific[0] = 1; - } - } - - // use (1 << 0) as contigunous is better supported. - - return true; - } -} // namespace Kernel - -#endif // ifndef __MODULE_NVME_HXX__ diff --git a/dev/zka/Modules/OHCI/.gitkeep b/dev/zka/Modules/OHCI/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/ReadMe.md b/dev/zka/Modules/ReadMe.md deleted file mode 100644 index 4dd0489f..00000000 --- a/dev/zka/Modules/ReadMe.md +++ /dev/null @@ -1,12 +0,0 @@ -# Kernel Modules. - -Pluggable modules for builtin hardware support within the Kernel. - -## Maintainers - -ACPI: Amlal EL Mahrouss. -AHCI: Amlal EL Mahrouss. -FB: Amlal EL Mahrouss. -PS2: Amlal EL Mahrouss. -ATA: Amlal EL Mahrouss. -MBCI: Amlal El Mahrouss. diff --git a/dev/zka/Modules/SCSI/.gitkeep b/dev/zka/Modules/SCSI/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/SCSI/SCSI.hxx b/dev/zka/Modules/SCSI/SCSI.hxx deleted file mode 100644 index 5283bc01..00000000 --- a/dev/zka/Modules/SCSI/SCSI.hxx +++ /dev/null @@ -1,14 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#pragma once - -#include - -/// @file SCSI.hxx -/// @brief Serial SCSI driver. - -typedef Kernel::UInt16 scsi_packet_type[12]; diff --git a/dev/zka/Modules/WiFi/.gitkeep b/dev/zka/Modules/WiFi/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/XHCI/.gitkeep b/dev/zka/Modules/XHCI/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/zka/Modules/XHCI/Defines.hxx b/dev/zka/Modules/XHCI/Defines.hxx deleted file mode 100644 index b882607c..00000000 --- a/dev/zka/Modules/XHCI/Defines.hxx +++ /dev/null @@ -1,70 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - File: Defines.hxx - Purpose: XHCI (and backwards) header. - - Revision History: - - 01/02/24: Added file (amlel) - 03/02/24: Update filename to Defines.hxx (amlel) - -------------------------------------------- */ - -#pragma once - -#include - -using namespace Kernel; - -#define kUSBCommand (UInt16)0x0 -#define kUSBStatus (UInt16)0x2 -#define kUSBInterruptEnable (UInt16)0x4 -#define kUSBFrameNum (UInt16)0x6 -#define kUSBFrameListBaseAddress (UInt16)0x8 -#define kUSBFrameModifyStart (UInt16)0xC -#define kUSBPort1StatusCtrl (UInt16)0x10 -#define kUSBPort2StatusCtrl (UInt16)0x12 - -typedef struct USBCommandRegister final -{ - UInt8 mReserved[8]; // Reserved - UInt8 - mMaxPacket; // 0 = Max packet size 32 bits 1 = Max packet size 64 bits - UInt8 mConfigure; - UInt8 mSoftwareDebug; - UInt8 mGlobalResume; - UInt8 mGlobalSuspend; - UInt8 mHostCtrlReset; - UInt8 mRun; // 1 = Controller execute frame list entries -} USBCommandRegister; - -typedef struct USBStatusRegister final -{ - UInt8 mReserved[8]; // Reserved - UInt8 mHalted; // 1 = bit 0 in CMD is zero 0 = bit 0 in CMD is 1 - UInt8 mProcessError; - UInt8 mSystemError; - UInt8 mResumeDetected; - UInt8 mErrorInterrupt; - UInt8 mInterrupt; -} USBStatusRegister; - -typedef struct USBInterruptEnableRegister final -{ - UInt8 mReserved[4]; // Reserved - UInt8 mShortPacket; // 1=Enable interrupt 0=Disable interrupt - UInt8 mComplete; // 1=Enable interrupt 0=Disable interrupt - UInt8 mResume; // 1=Enable interrupt 0=Disable interrupt - UInt8 mTimeoutCRC; // 1=Enable interrupt 0=Disable interrupt -} USBInterruptEnableRegister; - -/* - Some terminology: - - Frame Number: Number of processed entry of the Frame List. - Frame List Base Address: - 32-bit physical adress of Frame List. Remember that first 12 bytes are - always 0. The Frame List must contain 1024 entries. -*/ diff --git a/dev/zka/NewKit/Defines.hxx b/dev/zka/NewKit/Defines.hxx index a758effc..22065b99 100644 --- a/dev/zka/NewKit/Defines.hxx +++ b/dev/zka/NewKit/Defines.hxx @@ -59,6 +59,10 @@ namespace Kernel using IntFast64 = __INT_FAST64_TYPE__; using PtrDiff = __PTRDIFF_TYPE__; + using SInt16 = Int16; + using SInt32 = Int32; + using SInt64 = Int64; + typedef UIntPtr* Ptr64; typedef UInt32* Ptr32; diff --git a/dev/zka/StorageKit/SCSI.hxx b/dev/zka/StorageKit/SCSI.hxx index 5a684052..84da51be 100644 --- a/dev/zka/StorageKit/SCSI.hxx +++ b/dev/zka/StorageKit/SCSI.hxx @@ -6,6 +6,6 @@ #pragma once -#include +#include extern const scsi_packet_type kCDRomPacketTemplate; diff --git a/dev/zka/amd64-efi.make b/dev/zka/amd64-efi.make index 3db23e83..5225caba 100644 --- a/dev/zka/amd64-efi.make +++ b/dev/zka/amd64-efi.make @@ -3,13 +3,13 @@ # This is the newoskrnl's makefile. ################################################## -CC = x86_64-w64-mingw32-g++ -LD = x86_64-w64-mingw32-ld +CC = x86_64-w64-mingw32-g++.exe +LD = x86_64-w64-mingw32-ld.exe CCFLAGS = -fshort-wchar -c -D__ZKA_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions \ -std=c++20 -D__ZKA_SUPPORT_NX__ -I../Vendor -D__FSKIT_USE_NEFS__ \ - -D__NEWOSKRNL__ -D__HAVE_ZKA_APIS__ -D__FREESTANDING__ -D__ZKA__ -I./ -I../ -I../ZBA + -D__NEWOSKRNL__ -D__HAVE_ZKA_APIS__ -D__FREESTANDING__ -D__ZKA__ -I./ -I../ -I../zba -ASM = nasm +ASM = nasm.exe DISK_DRV = diff --git a/dev/zka/src/DriveMgr.cxx b/dev/zka/src/DriveMgr.cxx index f237458a..4b51cf66 100644 --- a/dev/zka/src/DriveMgr.cxx +++ b/dev/zka/src/DriveMgr.cxx @@ -8,9 +8,9 @@ #include #include -#include -#include -#include +#include +#include +#include /// @file DriveMgr.cxx /// @brief Kernel drive manager. diff --git a/dev/zka/src/FS/NeFS.cxx b/dev/zka/src/FS/NeFS.cxx index 61a18ae2..1e92ca02 100644 --- a/dev/zka/src/FS/NeFS.cxx +++ b/dev/zka/src/FS/NeFS.cxx @@ -6,9 +6,9 @@ #ifdef __FSKIT_USE_NEFS__ -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/dev/zka/src/Stop.cxx b/dev/zka/src/Stop.cxx index 9fdc982a..6c252206 100644 --- a/dev/zka/src/Stop.cxx +++ b/dev/zka/src/Stop.cxx @@ -11,10 +11,10 @@ #include #include #include -#include +#include #include -#include -#include +#include +#include #define cWebsiteMacro "https://help.el-mahrouss-logic.com/" -- cgit v1.2.3