diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-04-03 09:20:28 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-04-03 09:20:28 +0200 |
| commit | 3facc32b746a44b0e3a91cbe1897127194396d1b (patch) | |
| tree | 0725ebbf35a18e6933596ea5c765ac81adf7834f | |
| parent | efc6b5d169d2b6eaabe7384141cec6054ae622a0 (diff) | |
MHR-3: See main changes below.
Kernel: Improve Disk interfaces regarding the struct they're using (all of them are using MountpountInterface now)
SystemLib: Start adding PowerPC code to the SystemLib to be cross compiled
as a PEF FAT binary.
Kernel: Adding new builtins to support a wide range of hardware.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
30 files changed, 301 insertions, 121 deletions
diff --git a/Private/Builtins/APM/.gitkeep b/Private/Builtins/APM/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Private/Builtins/APM/.gitkeep diff --git a/Private/Builtins/ATA/Defines.hxx b/Private/Builtins/ATA/Defines.hxx index 0a07bc68..a8cabe77 100644 --- a/Private/Builtins/ATA/Defines.hxx +++ b/Private/Builtins/ATA/Defines.hxx @@ -16,7 +16,7 @@ #include <CompilerKit/CompilerKit.hxx> #include <NewKit/Defines.hpp> -// Status register +///! Status register #define ATA_SR_BSY 0x80 #define ATA_SR_DRDY 0x40 #define ATA_SR_DF 0x20 @@ -26,7 +26,7 @@ #define ATA_SR_IDX 0x02 #define ATA_SR_ERR 0x01 -// Error register +///! Error register #define ATA_ER_BBK 0x80 #define ATA_ER_UNC 0x40 #define ATA_ER_MC 0x20 @@ -50,6 +50,7 @@ #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 @@ -65,7 +66,7 @@ #define ATA_MASTER 0x00 #define ATA_SLAVE 0x01 -// Register +///! Register #define ATA_REG_DATA 0x00 #define ATA_REG_ERROR 0x01 #define ATA_REG_FEATURES 0x01 @@ -91,28 +92,30 @@ #define ATA_PRIMARY_DCR_AS 0x3F6 #define ATA_SECONDARY_DCR_AS 0x376 -// Irq +///! Irq #define ATA_PRIMARY_IRQ 14 #define ATA_SECONDARY_IRQ 15 -// Channels +///! Channels #define ATA_PRIMARY 0x00 #define ATA_SECONDARY 0x01 #define ATA_CYL_LOW 4 #define ATA_CYL_HIGH 5 -// IO Direction +///! IO Direction #define ATA_READ 0x00 #define ATA_WRITE 0x013 #define ATA_PRIMARY_SEL 0xA0 #define ATA_SECONDARY_SEL 0xB0 -// ATA Helpers +///! 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 512 diff --git a/Private/Builtins/MBCI/Defines.hxx b/Private/Builtins/MBCI/Defines.hxx new file mode 100644 index 00000000..b347485c --- /dev/null +++ b/Private/Builtins/MBCI/Defines.hxx @@ -0,0 +1,13 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include <NewKit/Defines.hpp> + +struct MBCIHostInterface; +struct MBCIDeviceInterface; +struct MBCIPacketInterface; diff --git a/Private/Builtins/OHCI/.gitkeep b/Private/Builtins/OHCI/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Private/Builtins/OHCI/.gitkeep diff --git a/Private/Builtins/README.TXT b/Private/Builtins/README.TXT index 4cb791f7..b090b2e5 100644 --- a/Private/Builtins/README.TXT +++ b/Private/Builtins/README.TXT @@ -8,9 +8,12 @@ What are these? These are NewOS builtins device drivers. -=========== -Maintainers -=========== +=================== +Maintainers/Authors +=================== -ACPIFactoryInterface: Amlal EL Mahrouss -AHCI: Amlal EL Mahrouss
\ No newline at end of file +ACPIFactoryInterface: Amlal EL Mahrouss. +AHCI: Amlal EL Mahrouss. +Toolbox: Amlal EL Mahrouss. +PS2: Amlal EL Mahrouss +ATA: Amlal EL Mahrouss
\ No newline at end of file diff --git a/Private/Builtins/SAS/.gitkeep b/Private/Builtins/SAS/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Private/Builtins/SAS/.gitkeep diff --git a/Private/Builtins/SAS/SCSI.hxx b/Private/Builtins/SAS/SCSI.hxx new file mode 100644 index 00000000..d7fb18d4 --- /dev/null +++ b/Private/Builtins/SAS/SCSI.hxx @@ -0,0 +1,14 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include <NewKit/Defines.hpp> + +/// @file SCSI.hxx +/// @brief Serial SCSI driver. + +typedef NewOS::UInt16 scsi_packet_type[12]; diff --git a/Private/KernelKit/DeviceManager.hpp b/Private/KernelKit/DeviceManager.hpp index 10d23604..0935c5b3 100644 --- a/Private/KernelKit/DeviceManager.hpp +++ b/Private/KernelKit/DeviceManager.hpp @@ -21,8 +21,10 @@ #include <NewKit/ErrorOr.hpp> #include <NewKit/Ref.hpp> +#define kDriveManagerCount 4U + // Last Rev -// Sat Feb 24 CET 2024 +// Wed, Apr 3, 2024 9:09:41 AM namespace NewOS { template <typename T> @@ -41,12 +43,12 @@ class DeviceInterface { DeviceInterface(const DeviceInterface<T> &) = default; public: - DeviceInterface<T> &operator<<(T Data) { + virtual DeviceInterface<T> &operator<<(T Data) { m_Out(Data); return *this; } - DeviceInterface<T> &operator>>(T Data) { + virtual DeviceInterface<T> &operator>>(T Data) { m_In(Data); return *this; } diff --git a/Private/KernelKit/DriveManager.hxx b/Private/KernelKit/DriveManager.hxx index d82c302b..d3d14f9a 100644 --- a/Private/KernelKit/DriveManager.hxx +++ b/Private/KernelKit/DriveManager.hxx @@ -54,11 +54,11 @@ struct DriveTrait final { Void (*fInput)(DrivePacket* packetPtr); Void (*fOutput)(DrivePacket* packetPtr); Void (*fVerify)(DrivePacket* packetPtr); + const Char* (*fDriveKind)(Void); }; -//! drive as a device. -typedef DeviceInterface<DriveTrait> DriveDevice; -typedef DriveDevice* DriveDevicePtr; +///! drive as a device. +typedef DriveTrait* DriveTraitPtr; /** * @brief Mounted drives interface. @@ -73,12 +73,12 @@ class MountpointInterface final { HCORE_COPY_DEFAULT(MountpointInterface); public: - DriveDevicePtr A() { return mA; } - DriveDevicePtr B() { return mB; } - DriveDevicePtr C() { return mC; } - DriveDevicePtr D() { return mD; } + DriveTraitPtr A() { return mA; } + DriveTraitPtr B() { return mB; } + DriveTraitPtr C() { return mC; } + DriveTraitPtr D() { return mD; } - DriveDevicePtr* GetAddressOf(Int32 index) { + DriveTraitPtr* GetAddressOf(Int32 index) { DbgLastError() = kErrorSuccess; switch (index) { @@ -102,22 +102,26 @@ class MountpointInterface final { } private: - DriveDevicePtr mA, mB, mC, mD = nullptr; + DriveTraitPtr mA, mB, mC, mD = nullptr; }; - /// @brief Unimplemented drive. /// @param pckt /// @return Void ke_drv_unimplemented(DriveTrait::DrivePacket* pckt); +/// @brief Gets the drive kind (ATA, SCSI, AHCI...) +/// @param +/// @return +const Char* ke_drive_kind(Void); + /// @brief Makes a new drive. /// @return the new drive. -DriveTrait construct_drive() noexcept; +DriveTrait construct_drive(void) noexcept; /// @brief Fetches the main drive. /// @return the new drive. -DriveTrait main_drive() noexcept; +DriveTrait main_drive(void) noexcept; } // namespace NewOS #endif /* ifndef __DRIVE_MANAGER__ */ diff --git a/Private/KernelRsrc.rc b/Private/KernelRsrc.rc index 3f5fffd3..0470d572 100644 --- a/Private/KernelRsrc.rc +++ b/Private/KernelRsrc.rc @@ -8,11 +8,11 @@ BEGIN BEGIN BLOCK "080904E4" BEGIN - VALUE "CompanyName", "Mahrouss Logic" - VALUE "FileDescription", "NewOS Microkernel for AMD64" + VALUE "CompanyName", "MahroussLogic" + VALUE "FileDescription", "NewOS microkernel." VALUE "FileVersion", "1.0" VALUE "InternalName", "NewKernel" - VALUE "LegalCopyright", "Mahrouss Logic" + VALUE "LegalCopyright", "MahroussLogic" VALUE "OriginalFilename", "NewKernel.exe" VALUE "ProductName", "NewKernel" VALUE "ProductVersion", "1.0" diff --git a/Private/Source/DriveManager.cxx b/Private/Source/DriveManager.cxx index 41a623c9..f79fcdf5 100644 --- a/Private/Source/DriveManager.cxx +++ b/Private/Source/DriveManager.cxx @@ -53,6 +53,21 @@ Void ke_drv_check_disk(DriveTrait::DrivePacket* pckt) { pckt->fPacketGood = false; } +/// @brief Gets the drive kind (ATA, SCSI, AHCI...) +/// @param +/// @return +#ifdef __ATA_PIO__ +const Char* ke_drive_kind(Void) { return "ATA-PIO"; } +#endif + +#ifdef __ATA_DMA__ +const Char* ke_drive_kind(Void) { return "ATA-DMA"; } +#endif + +#ifdef __AHCI__ +const Char* ke_drive_kind(Void) { return "AHCO"; } +#endif + /// @brief Unimplemented drive. /// @param pckt /// @return diff --git a/Private/Source/NewFS+IO.cxx b/Private/Source/NewFS+IO.cxx index 8264f7fa..63db9b1a 100644 --- a/Private/Source/NewFS+IO.cxx +++ b/Private/Source/NewFS+IO.cxx @@ -24,8 +24,8 @@ /// Useful macros. -#define NEWFS_WRITE(DRV, TRAITS, MP) (*MP->DRV()) << TRAITS -#define NEWFS_READ(DRV, TRAITS, MP) (*MP->DRV()) >> TRAITS +#define NEWFS_WRITE(DRV, TRAITS, MP) (*MP->DRV()).fOutput(&TRAITS) +#define NEWFS_READ(DRV, TRAITS, MP) (*MP->DRV()).fInput(&TRAITS) using namespace NewOS; @@ -41,19 +41,19 @@ Int32 fs_newfs_read_raw(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 Dr switch (DrvIndex) { case kHCFSSubDriveA: { - NEWFS_READ(A, DrvTrait, Mnt); + NEWFS_READ(A, DrvTrait.fPacket, Mnt); break; } case kHCFSSubDriveB: { - NEWFS_READ(B, DrvTrait, Mnt); + NEWFS_READ(B, DrvTrait.fPacket, Mnt); break; } case kHCFSSubDriveC: { - NEWFS_READ(C, DrvTrait, Mnt); + NEWFS_READ(C, DrvTrait.fPacket, Mnt); break; } case kHCFSSubDriveD: { - NEWFS_READ(D, DrvTrait, Mnt); + NEWFS_READ(D, DrvTrait.fPacket, Mnt); break; } } @@ -73,19 +73,19 @@ Int32 fs_newfs_write_raw(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 D switch (DrvIndex) { case kHCFSSubDriveA: { - NEWFS_WRITE(A, DrvTrait, Mnt); + NEWFS_WRITE(A, DrvTrait.fPacket, Mnt); break; } case kHCFSSubDriveB: { - NEWFS_WRITE(B, DrvTrait, Mnt); + NEWFS_WRITE(B, DrvTrait.fPacket, Mnt); break; } case kHCFSSubDriveC: { - NEWFS_WRITE(C, DrvTrait, Mnt); + NEWFS_WRITE(C, DrvTrait.fPacket, Mnt); break; } case kHCFSSubDriveD: { - NEWFS_WRITE(D, DrvTrait, Mnt); + NEWFS_WRITE(D, DrvTrait.fPacket, Mnt); break; } } diff --git a/Private/Source/Storage/AHCIDeviceInterface.cxx b/Private/Source/Storage/AHCIDeviceInterface.cxx index c6a4a4be..c7a99cb0 100644 --- a/Private/Source/Storage/AHCIDeviceInterface.cxx +++ b/Private/Source/Storage/AHCIDeviceInterface.cxx @@ -12,8 +12,8 @@ using namespace NewOS; /// @param Out Disk output /// @param In Disk input /// @param Cleanup Disk cleanup. -AHCIDeviceInterface::AHCIDeviceInterface(void (*Out)(AHCIPacket outpacket), - void (*In)(AHCIPacket inpacket), void (*Cleanup)(void)) +AHCIDeviceInterface::AHCIDeviceInterface(void (*Out)(MountpointInterface* outpacket), + void (*In)(MountpointInterface* inpacket), void (*Cleanup)(void)) : DeviceInterface(Out, In), fCleanup(Cleanup) {} /// @brief Class desctructor diff --git a/Private/Source/Storage/ATADeviceInterface.cxx b/Private/Source/Storage/ATADeviceInterface.cxx new file mode 100644 index 00000000..89f11f5d --- /dev/null +++ b/Private/Source/Storage/ATADeviceInterface.cxx @@ -0,0 +1,68 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <StorageKit/ATA.hpp> + +using namespace NewOS; + +/// @brief Class constructor +/// @param Out Disk output +/// @param In Disk input +/// @param Cleanup Disk cleanup. +ATADeviceInterface::ATADeviceInterface( + void (*Out)(MountpointInterface* outpacket), + void (*In)(MountpointInterface* inpacket), void (*Cleanup)(void)) + : DeviceInterface(Out, In), fCleanup(Cleanup) {} + +/// @brief Class desctructor +ATADeviceInterface::~ATADeviceInterface() { + MUST_PASS(fCleanup); + if (fCleanup) fCleanup(); +} + +/// @brief Returns the name of the device interface. +/// @return it's name as a string. +const char* ATADeviceInterface::Name() const { return "ATADeviceInterface"; } + +/// @brief Output operator. +/// @param Data +/// @return +ATADeviceInterface& ATADeviceInterface::operator<<(MountpointInterface* Data) { + if (!Data) return *this; + + for (SizeT driveCount = 0; driveCount < kDriveManagerCount; ++driveCount) { + auto interface = Data->GetAddressOf(driveCount); + if ((*interface) && rt_string_cmp((*interface)->fDriveKind(), "ATA-", 5) == 0) { + continue; + } else if ((*interface) && + rt_string_cmp((*interface)->fDriveKind(), "ATA-", 5) != 0) { + return *this; + } + } + + return (ATADeviceInterface&)DeviceInterface<MountpointInterface*>::operator<<( + Data); +} + +/// @brief Input operator. +/// @param Data +/// @return +ATADeviceInterface& ATADeviceInterface::operator>>(MountpointInterface* Data) { + if (!Data) return *this; + + for (SizeT driveCount = 0; driveCount < kDriveManagerCount; ++driveCount) { + auto interface = Data->GetAddressOf(driveCount); + if ((*interface) && rt_string_cmp((*interface)->fDriveKind(), "ATA-", 5) == 0) { + continue; + } else if ((*interface) && + rt_string_cmp((*interface)->fDriveKind(), "ATA-", 5) != 0) { + return *this; + } + } + + return (ATADeviceInterface&)DeviceInterface<MountpointInterface*>::operator>>( + Data); +}
\ No newline at end of file diff --git a/Private/Source/Storage/StorageBase.cxx b/Private/Source/Storage/SCSIDeviceInterface.cxx index bba4be1f..7625a279 100644 --- a/Private/Source/Storage/StorageBase.cxx +++ b/Private/Source/Storage/SCSIDeviceInterface.cxx @@ -4,8 +4,8 @@ ------------------------------------------- */ -#include <StorageKit/Storage.hpp> +#include <StorageKit/SCSI.hxx> ///! @brief ATAPI SCSI packet. -const SKScsiPacket kCDRomPacketTemplate = {0x43, 0, 1, 0, 0, 0, +const scsi_packet_type kCDRomPacketTemplate = {0x43, 0, 1, 0, 0, 0, 0, 12, 0x40, 0, 0}; diff --git a/Private/StorageKit/AHCI.hpp b/Private/StorageKit/AHCI.hpp index 6f5b5a90..08548a1c 100644 --- a/Private/StorageKit/AHCI.hpp +++ b/Private/StorageKit/AHCI.hpp @@ -7,15 +7,14 @@ #pragma once #include <KernelKit/DeviceManager.hpp> +#include <KernelKit/DriveManager.hxx> #include <NewKit/OwnPtr.hpp> namespace NewOS { -class AHCIPacket; - -class AHCIDeviceInterface : public DeviceInterface<AHCIPacket> { +class AHCIDeviceInterface : public DeviceInterface<MountpointInterface*> { public: - explicit AHCIDeviceInterface(void (*Out)(AHCIPacket outpacket), - void (*In)(AHCIPacket inpacket), + explicit AHCIDeviceInterface(void (*Out)(MountpointInterface* outpacket), + void (*In)(MountpointInterface* inpacket), void (*Cleanup)(void)); virtual ~AHCIDeviceInterface(); @@ -27,17 +26,6 @@ class AHCIDeviceInterface : public DeviceInterface<AHCIPacket> { const char *Name() const override; private: - void (*fOut)(AHCIPacket); - void (*fIn)(AHCIPacket); void (*fCleanup)(void); }; - -class AHCIPacket final { - UIntPtr DataPtr; - SizeT DataSz; - UInt8 PortId; - UInt8 PortRdy; - Lba BeginLba; - Lba SectorCnt; -}; } // namespace NewOS
\ No newline at end of file diff --git a/Private/StorageKit/ATA.hpp b/Private/StorageKit/ATA.hpp index 5ad5a2d4..da3c8d23 100644 --- a/Private/StorageKit/ATA.hpp +++ b/Private/StorageKit/ATA.hpp @@ -7,19 +7,24 @@ #pragma once #include <KernelKit/DeviceManager.hpp> +#include <KernelKit/DriveManager.hxx> #include <NewKit/OwnPtr.hpp> +#include <NewKit/Utils.hpp> namespace NewOS { -class ATAPacket; - -class ATADeviceInterface : public DeviceInterface<ATAPacket> { +/// @brief ATA device interface type. +class ATADeviceInterface : public DeviceInterface<MountpointInterface*> { public: - explicit ATADeviceInterface(void (*Out)(ATAPacket outpacket), - void (*In)(ATAPacket inpacket), + explicit ATADeviceInterface(void (*Out)(MountpointInterface* outpacket), + void (*In)(MountpointInterface* inpacket), void (*Cleanup)(void)); virtual ~ATADeviceInterface(); +public: + ATADeviceInterface &operator<<(MountpointInterface* Data) override; + ATADeviceInterface &operator>>(MountpointInterface* Data) override; + public: ATADeviceInterface &operator=(const ATADeviceInterface &) = default; ATADeviceInterface(const ATADeviceInterface &) = default; @@ -27,17 +32,6 @@ class ATADeviceInterface : public DeviceInterface<ATAPacket> { const char *Name() const override; private: - void (*fOut)(ATAPacket); - void (*fIn)(ATAPacket); void (*fCleanup)(void); }; - -class ATAPacket final { - UIntPtr DataPtr; - SizeT DataSz; - UInt8 PortId; - UInt8 PortRdy; - Lba BeginLba; - Lba SectorCnt; -}; } // namespace NewOS
\ No newline at end of file diff --git a/Private/StorageKit/NVME.hpp b/Private/StorageKit/NVME.hpp index d2ed585f..dc7b37d8 100644 --- a/Private/StorageKit/NVME.hpp +++ b/Private/StorageKit/NVME.hpp @@ -7,15 +7,14 @@ #pragma once #include <KernelKit/DeviceManager.hpp> +#include <KernelKit/DriveManager.hxx> #include <NewKit/OwnPtr.hpp> namespace NewOS { -class NVMEPacket; - -class NVMEDeviceInterface : public DeviceInterface<NVMEPacket> { +class NVMEDeviceInterface : public DeviceInterface<MountpointInterface*> { public: - explicit NVMEDeviceInterface(void (*Out)(NVMEPacket outpacket), - void (*In)(NVMEPacket inpacket), void (*Cleanup)(void)) + explicit NVMEDeviceInterface(void (*Out)(MountpointInterface* outpacket), + void (*In)(MountpointInterface* inpacket), void (*Cleanup)(void)) : DeviceInterface(Out, In), fCleanup(Cleanup) {} virtual ~NVMEDeviceInterface() { @@ -29,17 +28,9 @@ class NVMEDeviceInterface : public DeviceInterface<NVMEPacket> { const char *Name() const override; public: - OwnPtr<NVMEPacket> operator()(UInt32 dmaLow, UInt32 dmaHigh, SizeT sz); + OwnPtr<MountpointInterface*> operator()(UInt32 dmaLow, UInt32 dmaHigh, SizeT sz); private: void (*fCleanup)(void); }; - -class NVMEPacket final { - UIntPtr DataPtr; - SizeT DataSz; - UInt8 Namespace; - Lba Begin; - Lba End; -}; } // namespace NewOS diff --git a/Private/StorageKit/SCSI.hxx b/Private/StorageKit/SCSI.hxx new file mode 100644 index 00000000..eb207c9d --- /dev/null +++ b/Private/StorageKit/SCSI.hxx @@ -0,0 +1,11 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include <Builtins/SAS/SCSI.hxx> + +extern const scsi_packet_type kCDRomPacketTemplate; diff --git a/Private/StorageKit/Storage.hpp b/Private/StorageKit/Storage.hpp index 8e7614e6..530e63bd 100644 --- a/Private/StorageKit/Storage.hpp +++ b/Private/StorageKit/Storage.hpp @@ -9,14 +9,8 @@ #include <NewKit/Defines.hpp> #include <StorageKit/NVME.hpp> #include <StorageKit/AHCI.hpp> +#include <StorageKit/SCSI.hxx> -typedef NewOS::UInt16 SKScsiPacket[12]; - -extern const SKScsiPacket kCDRomPacketTemplate; - -#define f_kDriveSectorSizeHDD (512) -#define f_kDriveSectorSizeSSD (4096) -#define f_kDriveSectorSizeCDROM (2048) - -#define f_kDriveSize(LAST_LBA) ((LAST_LBA + 1) * f_kDriveSectorSize) - +#define kDriveSectorSizeHDD (512) +#define kDriveSectorSizeSSD (4096) +#define kDriveSectorSizeCDROM (2048) diff --git a/Public/Developer/HTMLLib/Headers/HTML.h b/Public/Developer/HTMLLib/Headers/HTML.h index 6618f99f..5da334ed 100644 --- a/Public/Developer/HTMLLib/Headers/HTML.h +++ b/Public/Developer/HTMLLib/Headers/HTML.h @@ -46,5 +46,5 @@ typedef struct _HtmlDOMElement { struct _HtmlDOMElement* fParentElement; } HtmlDOMElement, *HtmlDOMElementRef; - +/// @brief Root element of the DOM. #define kHtmlRootElement "document" diff --git a/Public/Developer/SystemLib/AMD64/CoreAssembly.s b/Public/Developer/SystemLib/AMD64/CoreAssembly.s index 58bb1260..1d361621 100644 --- a/Public/Developer/SystemLib/AMD64/CoreAssembly.s +++ b/Public/Developer/SystemLib/AMD64/CoreAssembly.s @@ -4,19 +4,19 @@ .section .text -.globl RtGetAppObject -.globl __assert_chk_fail +.globl RtGetApp +.globl RtAssertTriggerInterrupt -/* @brief Process object getter */ +/* @brief Application getter */ /* @throws: ApptError: appartement error. */ -RtGetAppObject: +RtGetApp: mov $0x10, %rcx /* sysGetProcessObject */ int $0x21 /* rax gets saved and returned. */ ret -__assert_chk_fail: +RtAssertTriggerInterrupt: mov $0x11, %rcx /* sysTerminateCurrentProcess */ int $0x21 diff --git a/Public/Developer/SystemLib/Headers/Defines.h b/Public/Developer/SystemLib/Headers/Defines.h index 6ab27497..d3b6b793 100644 --- a/Public/Developer/SystemLib/Headers/Defines.h +++ b/Public/Developer/SystemLib/Headers/Defines.h @@ -11,7 +11,7 @@ #endif #ifdef _DEBUG -#define CA_MUST_PASS(e) { if (!e) { DlgMsgBox("Sorry, an assertion failed.\nFile: %s\nLine: %i", __FILE__, __LINE__) __assert_chk_fail() } } +#define CA_MUST_PASS(e) { if (!e) { DlgMsgBox("Sorry, an assertion failed.\nFile: %s\nLine: %i", __FILE__, __LINE__) RtAssertTriggerInterrupt() } } #else #define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e) #endif @@ -29,7 +29,7 @@ struct Application; struct GUID; -CA_EXTERN_C void __assert_chk_fail(void); +CA_EXTERN_C void RtAssertTriggerInterrupt(void); #define CA_STDCALL __attribute__((stdcall)) #define CA_CDECL __attribute__((cdecl)) @@ -115,6 +115,10 @@ enum RtProcessCall { /// @brief Open a specific handle (can be used as sel to call methods related to it.) kCallOpenFile, kCallCloseFile, + kCallOpenDir, + kCallCloseDir, + kCallOpenDevice, + kCallCloseDevice, kCallCreateWindow, kCallCloseWindow, kCallCreateMenu, @@ -180,9 +184,20 @@ using StrType = CharacterTypeUTF8[N]; #endif // ifdef C++ -CA_EXTERN_C ApplicationRef RtGetAppObject(VoidType); +/// @brief Get app singleton. +/// @param +/// @return +CA_EXTERN_C ApplicationRef RtGetApp(VoidType); + +/// @brief Get argument count +/// @param +/// @return CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType); -CA_EXTERN_C CharacterTypeUTF8* RtGetAppArgumentsPtr(VoidType); + +/// @brief Get argument pointer. +/// @param +/// @return +CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType); CA_EXTERN_C ApplicationRef kSharedApplication; diff --git a/Public/Developer/SystemLib/Headers/File.h b/Public/Developer/SystemLib/Headers/File.h index 6333bf6a..5e58d104 100644 --- a/Public/Developer/SystemLib/Headers/File.h +++ b/Public/Developer/SystemLib/Headers/File.h @@ -23,8 +23,6 @@ CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, const CharacterTypeU /// @return CA_EXTERN_C VoidType FsCloseFile(FSRef refFs); -typedef QWordType FSForkRef; - /// @brief A fork information header. typedef struct _Fork { PtrVoidType forkData; @@ -34,6 +32,8 @@ typedef struct _Fork { CharacterTypeUTF8 forkName[256]; } ForkType; +typedef ForkType* FSForkRef; + /// @brief Gets the fork inside a file. /// @param refFs the filesystem ref /// @param forkName the fork's name diff --git a/Public/Developer/SystemLib/Makefile b/Public/Developer/SystemLib/Makefile index f7a30572..a753ccc8 100644 --- a/Public/Developer/SystemLib/Makefile +++ b/Public/Developer/SystemLib/Makefile @@ -5,7 +5,6 @@ CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar -ARFLAGS=-rcs CCINC=-I./ CCFLAGS=-D__SINGLE_PRECISION__ -nostdlib -std=c17 -ffreestanding -Xlinker --subsystem=17 -shared OUTPUT=SystemLib.lib diff --git a/Public/Developer/SystemLib/PowerPC/CoreAssembly.s b/Public/Developer/SystemLib/PowerPC/CoreAssembly.s new file mode 100644 index 00000000..7fef98e3 --- /dev/null +++ b/Public/Developer/SystemLib/PowerPC/CoreAssembly.s @@ -0,0 +1,26 @@ +/** =========================================== + (C) Mahrouss Logic + Purpose: PowerPC low-level routines. + ===========================================*/ + +.section .text + +.globl RtGetApp +.globl RtAssertTriggerInterrupt +.balign 4 + +/* @brief Application getter */ +/* @throws: ApptError: appartement error. */ +RtGetApp: + stw 0x10, 0(3) /* sysGetProcessObject */ + sc + + blr + +RtAssertTriggerInterrupt: + stw 0x11, 0(3) /* sysTerminateCurrentProcess */ + stw 0x3, 0(4) + sc + + blr + diff --git a/Public/Developer/SystemLib/Sources/Application.c b/Public/Developer/SystemLib/Sources/Application.c index d7a83d3e..f1391975 100644 --- a/Public/Developer/SystemLib/Sources/Application.c +++ b/Public/Developer/SystemLib/Sources/Application.c @@ -6,7 +6,7 @@ #include <Headers/Defines.h> -/// @brief Main Application object, retrieved from the RtGetAppObject symbol. +/// @brief Main Application object, retrieved from the RtGetApp symbol. ApplicationRef kSharedApplication = NullPtr; /// @brief Gets the app arguments count. @@ -19,7 +19,7 @@ CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) { /// @brief Gets the app arguments pointer. /// @param void no arguments. /// @return -CA_EXTERN_C CharacterTypeUTF8* RtGetAppArgumentsPtr(VoidType) { - return (CharacterTypeUTF8*)kSharedApplication->Invoke(kSharedApplication, +CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType) { + return (CharacterTypeUTF8**)kSharedApplication->Invoke(kSharedApplication, kCallGetArgsPtr); }
\ No newline at end of file diff --git a/Public/Developer/SystemLib/Sources/ApplicationStart.c b/Public/Developer/SystemLib/Sources/ApplicationStart.c index 5b91ba18..0960388e 100644 --- a/Public/Developer/SystemLib/Sources/ApplicationStart.c +++ b/Public/Developer/SystemLib/Sources/ApplicationStart.c @@ -9,6 +9,6 @@ /// @brief Inits the system library. /// @return if it was succesful or not. CA_EXTERN_C VoidType __start(VoidType) { - kSharedApplication = RtGetAppObject(); + kSharedApplication = RtGetApp(); CA_MUST_PASS(kSharedApplication); } diff --git a/Public/Developer/SystemLib/Sources/File.c b/Public/Developer/SystemLib/Sources/File.c new file mode 100644 index 00000000..1432e7e0 --- /dev/null +++ b/Public/Developer/SystemLib/Sources/File.c @@ -0,0 +1,38 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <Headers/Defines.h> +#include <Headers/File.h> + +enum FileOp { + kFlushFile, + kReadFork, + kWriteFork, + kOpenFork, + kCloseFork, +}; + +/// @brief Opens a new file. +/// @param path where to find it. +/// @param r the restrict (rw, rwe, r+, w+, r, w) +/// @return +CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r) { + CA_MUST_PASS(kSharedApplication); + CA_MUST_PASS(path); + CA_MUST_PASS(r); + + return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path, r); +} + +/// @brief Closes the file and flushes it to the said file. +/// @param refFs the filesystem reference. +/// @return +CA_EXTERN_C VoidType FsCloseFile(FSRef refFs) { + CA_MUST_PASS(kSharedApplication); + + kSharedApplication->Invoke(kSharedApplication, refFs, kFlushFile); + kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refFs); +}
\ No newline at end of file diff --git a/Public/Developer/SystemLib/Sources/Heap.c b/Public/Developer/SystemLib/Sources/Heap.c index c866ef5d..041c5764 100644 --- a/Public/Developer/SystemLib/Sources/Heap.c +++ b/Public/Developer/SystemLib/Sources/Heap.c @@ -4,25 +4,27 @@ ------------------------------------------- */ +#include <Headers/Defines.h> #include <Headers/Heap.h> /// @brief Allocate from the user's heap. /// @param sz size of object. /// @param flags flags. /// @return -CA_EXTERN_C PtrVoidType RtTlsAllocate(QWordType sz, - DWordType flags) { +CA_EXTERN_C PtrVoidType RtTlsAllocate(QWordType sz, DWordType flags) { CA_MUST_PASS(sz); CA_MUST_PASS(flags); - return (PtrVoidType)kSharedApplication->Invoke(kSharedApplication, kCallAllocPtr, sz, flags); + return (PtrVoidType)kSharedApplication->Invoke(kSharedApplication, + kCallAllocPtr, sz, flags); } /// @brief Free pointer from the user's heap. /// @param ptr the pointer to free. CA_EXTERN_C VoidType RtTlsFree(PtrVoidType ptr) { CA_MUST_PASS(ptr); - CA_UNREFERENCED_PARAMETER(kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr)); + CA_UNREFERENCED_PARAMETER( + kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr)); } /// @brief Get pointer size. |
