summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/Kernel/CFKit/Property.h6
-rw-r--r--dev/Kernel/HALKit/AMD64/HalApplicationProcessor.cc1
-rw-r--r--dev/Kernel/HALKit/AMD64/Storage/SATA.cc33
-rw-r--r--dev/Kernel/NewKit/Array.h7
-rw-r--r--dev/Kernel/NewKit/ArrayList.h13
-rw-r--r--dev/LibSCI/GPU.h13
-rw-r--r--dev/LibSCI/Macros.h15
-rw-r--r--dev/Mod/AHCI/AHCI.h6
-rw-r--r--dev/Usr/LibCF/Array.h63
-rw-r--r--dev/Usr/LibCF/Property.h53
-rw-r--r--dev/Usr/LibCF/Ref.h106
-rw-r--r--dev/Usr/LibCompress/API.h18
-rw-r--r--dev/Usr/LibCompress/LCCompress.s7
-rw-r--r--dev/Usr/LibCompress/LCDecompress.s7
-rw-r--r--dev/Usr/LibSystem/.keepme0
-rw-r--r--dev/Usr/LibWS/.keepme0
16 files changed, 281 insertions, 67 deletions
diff --git a/dev/Kernel/CFKit/Property.h b/dev/Kernel/CFKit/Property.h
index 54e028ed..b43434f6 100644
--- a/dev/Kernel/CFKit/Property.h
+++ b/dev/Kernel/CFKit/Property.h
@@ -13,7 +13,7 @@
#include <NewKit/KString.h>
#include <CFKit/GUIDWrapper.h>
-#define kMaxPropLen (255U)
+#define kMaxPropLen (256U)
namespace CFKit
{
@@ -23,7 +23,7 @@ namespace CFKit
using PropertyId = UIntPtr;
/// @brief Kernel property class.
- /// @example /Properties/SmpCoreClass or /Properties/KernelVersionClass
+ /// @example /prop/smp_max or /prop/kern_ver
class Property
{
public:
@@ -34,7 +34,7 @@ namespace CFKit
Property& operator=(const Property&) = default;
Property(const Property&) = default;
- bool StringEquals(KString& name);
+ BOOL StringEquals(KString& name);
PropertyId& GetValue();
KString& GetKey();
diff --git a/dev/Kernel/HALKit/AMD64/HalApplicationProcessor.cc b/dev/Kernel/HALKit/AMD64/HalApplicationProcessor.cc
index fc25b3d8..627f3fcb 100644
--- a/dev/Kernel/HALKit/AMD64/HalApplicationProcessor.cc
+++ b/dev/Kernel/HALKit/AMD64/HalApplicationProcessor.cc
@@ -4,7 +4,6 @@
------------------------------------------- */
-#include "NewKit/Macros.h"
#include <Mod/ACPI/ACPIFactoryInterface.h>
#include <KernelKit/UserProcessScheduler.h>
#include <HALKit/AMD64/Processor.h>
diff --git a/dev/Kernel/HALKit/AMD64/Storage/SATA.cc b/dev/Kernel/HALKit/AMD64/Storage/SATA.cc
index 1435cfac..56afa303 100644
--- a/dev/Kernel/HALKit/AMD64/Storage/SATA.cc
+++ b/dev/Kernel/HALKit/AMD64/Storage/SATA.cc
@@ -15,7 +15,6 @@
*
*/
-#include "NewKit/Macros.h"
#include <KernelKit/UserProcessScheduler.h>
#include <KernelKit/LPC.h>
@@ -33,12 +32,12 @@
#define kHBAPxCmdFR 0x4000
#define kHBAPxCmdCR 0x8000
-#define kSataLBAMode (1 << 6)
+#define kSATALBAMode (1 << 6)
-#define kAhciSRBsy (0x80)
-#define kAhciSRDrq (0x08)
+#define kSATASRBsy (0x80)
+#define kSATASRDrq (0x08)
-#define kAhciPortCnt (0x20)
+#define kSATAPortCnt (0x20)
#define kSATAProgIfAHCI (0x01)
#define kSATASubClass (0x06)
@@ -50,7 +49,7 @@ STATIC Kernel::SizeT kSATAPortIdx = 0UL;
STATIC Kernel::Lba kCurrentDiskSectorCount = 0UL;
template <BOOL Write, BOOL CommandOrCTRL, BOOL Identify>
-static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buffer, Kernel::SizeT sector_sz, Kernel::SizeT size_buffer) noexcept;
+static Kernel::Void drvi_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buffer, Kernel::SizeT sector_sz, Kernel::SizeT size_buffer) noexcept;
static Kernel::Int32 drvi_find_cmd_slot(HbaPort* port) noexcept;
@@ -62,7 +61,7 @@ static Kernel::Void drvi_calculate_disk_geometry() noexcept
Kernel::UInt8 identify_data[kib_cast(4)] = {};
- drv_std_input_output<NO, YES, YES>(0, identify_data, 0, kib_cast(4));
+ drvi_std_input_output<NO, YES, YES>(0, identify_data, 0, kib_cast(4));
kCurrentDiskSectorCount = (identify_data[61] << 16) | identify_data[60];
@@ -95,10 +94,10 @@ Kernel::Boolean drv_std_init(Kernel::UInt16& PortsImplemented)
Kernel::UInt32 ports_implemented = mem_ahci->Pi;
Kernel::UInt16 ahci_index = 0;
- const Kernel::UInt16 kMaxPortsImplemented = kAhciPortCnt;
+ const Kernel::UInt16 kMaxPortsImplemented = kSATAPortCnt;
const Kernel::UInt32 kSATASignature = 0x00000101;
- const Kernel::UInt8 kAhciPresent = 0x03;
- const Kernel::UInt8 kAhciIPMActive = 0x01;
+ const Kernel::UInt8 kSATAPresent = 0x03;
+ const Kernel::UInt8 kSATAIPMActive = 0x01;
while (ahci_index < kMaxPortsImplemented)
{
@@ -163,19 +162,19 @@ Kernel::Boolean drv_std_detected(Kernel::Void)
Kernel::Void drv_std_write(Kernel::UInt64 lba, Kernel::Char* buffer, Kernel::SizeT sector_sz, Kernel::SizeT size_buffer)
{
- drv_std_input_output<YES, YES, NO>(lba, (Kernel::UInt8*)buffer, sector_sz, size_buffer);
+ drvi_std_input_output<YES, YES, NO>(lba, (Kernel::UInt8*)buffer, sector_sz, size_buffer);
}
Kernel::Void drv_std_read(Kernel::UInt64 lba, Kernel::Char* buffer, Kernel::SizeT sector_sz, Kernel::SizeT size_buffer)
{
- drv_std_input_output<NO, YES, NO>(lba, (Kernel::UInt8*)buffer, sector_sz, size_buffer);
+ drvi_std_input_output<NO, YES, NO>(lba, (Kernel::UInt8*)buffer, sector_sz, size_buffer);
}
static Kernel::Int32 drvi_find_cmd_slot(HbaPort* port) noexcept
{
Kernel::UInt32 slots = port->Ci;
- for (Kernel::Int32 i = 0; i < (kAhciPortCnt); i++)
+ for (Kernel::Int32 i = 0; i < (kSATAPortCnt); i++)
{
if ((slots & 1) == 0)
return i;
@@ -187,7 +186,7 @@ static Kernel::Int32 drvi_find_cmd_slot(HbaPort* port) noexcept
}
template <BOOL Write, BOOL CommandOrCTRL, BOOL Identify>
-static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buffer, Kernel::SizeT sector_sz, Kernel::SizeT size_buffer) noexcept
+static Kernel::Void drvi_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buffer, Kernel::SizeT sector_sz, Kernel::SizeT size_buffer) noexcept
{
auto slot = 0L;
@@ -237,14 +236,14 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff
h2d_fis->Lba4 = (lba >> 32) & 0xFF;
h2d_fis->Lba5 = (lba >> 40) & 0xFF;
- h2d_fis->Device = kSataLBAMode;
+ h2d_fis->Device = kSATALBAMode;
// 28-bit LBA mode, fis is done being configured.
h2d_fis->CountLow = sector_sz & 0xFF;
h2d_fis->CountHigh = (sector_sz >> 8) & 0xFF;
- while ((kSATAPort->Ports[kSATAPortIdx].Tfd & (kAhciSRBsy | kAhciSRDrq)))
+ while ((kSATAPort->Ports[kSATAPortIdx].Tfd & (kSATASRBsy | kSATASRDrq)))
{
kout << "Waiting for the TFD to be ready...\r";
}
@@ -267,7 +266,7 @@ static Kernel::Void drv_std_input_output(Kernel::UInt64 lba, Kernel::UInt8* buff
kout << "TFD: " << Kernel::hex_number(kSATAPort->Ports[kSATAPortIdx].Tfd) << endl;
}
- while ((kSATAPort->Ports[kSATAPortIdx].Tfd & (kAhciSRBsy | kAhciSRDrq)))
+ while ((kSATAPort->Ports[kSATAPortIdx].Tfd & (kSATASRBsy | kSATASRDrq)))
{
kout << "Waiting for the TFD to be ready...\r";
}
diff --git a/dev/Kernel/NewKit/Array.h b/dev/Kernel/NewKit/Array.h
index f44caae3..aab3ba91 100644
--- a/dev/Kernel/NewKit/Array.h
+++ b/dev/Kernel/NewKit/Array.h
@@ -24,6 +24,7 @@ namespace Kernel
T& operator[](const SizeT& at)
{
+ MUST_PASS(at < this->Count());
return fArray[at];
}
@@ -55,4 +56,10 @@ namespace Kernel
private:
T fArray[N];
};
+
+ template <typename ValueType>
+ auto make_list(ValueType val)
+ {
+ return Array<ValueType, ARRAY_SIZE(val)>{val};
+ }
} // namespace Kernel
diff --git a/dev/Kernel/NewKit/ArrayList.h b/dev/Kernel/NewKit/ArrayList.h
index 88d67daa..6d799ad5 100644
--- a/dev/Kernel/NewKit/ArrayList.h
+++ b/dev/Kernel/NewKit/ArrayList.h
@@ -14,7 +14,7 @@ namespace Kernel
class ArrayList final
{
public:
- explicit ArrayList(T* list)
+ explicit ArrayList(T* list, SizeT length)
: fList(reinterpret_cast<T>(list))
{
}
@@ -36,6 +36,7 @@ namespace Kernel
T& operator[](int index) const
{
+ MUST_PASS(index < this->Count());
return fList[index];
}
@@ -44,10 +45,14 @@ namespace Kernel
return fList;
}
- private:
- T* fList;
+ SizeT Count()
+ {
+ return fLen;
+ }
- friend class InitHelpers;
+ private:
+ T* fList{nullptr};
+ SizeT fLen{0};
};
template <typename ValueType>
diff --git a/dev/LibSCI/GPU.h b/dev/LibSCI/GPU.h
index 892a85ff..6ee937f5 100644
--- a/dev/LibSCI/GPU.h
+++ b/dev/LibSCI/GPU.h
@@ -23,21 +23,20 @@ struct GPUCmdBuffer;
/// ------------------------------------------------------------------------------------------ //
struct GPUCmdBuffer final
{
- SizeT X, Y, Z;
- VoidPtr FrameData;
- SizeT FrameDataSz;
- SizeT BackBufferLayer;
+ VoidPtr Data;
+ SizeT DataSz;
+ SizeT BufferLayer;
Bool IsGPGPUData;
- Bool BackBufferFirst;
+ Bool BufferFirst;
Bool isGPGPUData()
{
- return !this->BackBufferFirst && this->IsGPGPUData;
+ return !this->BufferFirst && this->IsGPGPUData;
}
Bool isValid()
{
- return this->FrameData && this->FrameDataSz > 0;
+ return this->Data && (this->DataSz > 0) && (MmGetHeapFlags(this->Data) != -1);
}
};
diff --git a/dev/LibSCI/Macros.h b/dev/LibSCI/Macros.h
index 5f4253de..62d522c9 100644
--- a/dev/LibSCI/Macros.h
+++ b/dev/LibSCI/Macros.h
@@ -54,3 +54,18 @@ typedef IOObject FSObject;
typedef SCIObject DLLObject;
typedef SCIObject ThreadObject;
typedef SCIObject SocketObject;
+
+#ifdef __cplusplus
+typedef decltype(nullptr) nullPtr;
+typedef decltype(nullptr) NullPtr;
+#endif
+
+EXTERN_C void _rtl_assert(Bool expr, const Char* origin);
+
+#define MUST_PASS(X) _rtl_assert(X, __FILE__)
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) \
+ (((sizeof(a) / sizeof(*(a))) / \
+ (static_cast<Kernel::Size>(!(sizeof(a) % sizeof(*(a)))))))
+#endif \ No newline at end of file
diff --git a/dev/Mod/AHCI/AHCI.h b/dev/Mod/AHCI/AHCI.h
index 8e457431..74b08e38 100644
--- a/dev/Mod/AHCI/AHCI.h
+++ b/dev/Mod/AHCI/AHCI.h
@@ -222,9 +222,9 @@ typedef struct FisDevBits final
} FisDevBits;
/// \brief Enable AHCI device bit in GHC register.
-#ifndef kAhciGHC_AE
-#define kAhciGHC_AE (31)
-#endif //! ifndef kAhciGHC_AE
+#ifndef kSATAGHC_AE
+#define kSATAGHC_AE (31)
+#endif //! ifndef kSATAGHC_AE
typedef struct HbaPort final
{
diff --git a/dev/Usr/LibCF/Array.h b/dev/Usr/LibCF/Array.h
new file mode 100644
index 00000000..8533b649
--- /dev/null
+++ b/dev/Usr/LibCF/Array.h
@@ -0,0 +1,63 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <LibSCI/SCI.h>
+
+namespace LibCF
+{
+ template <typename T, SizeT N>
+ class CFArray final
+ {
+ public:
+ explicit CFArray() = default;
+ ~CFArray() = default;
+
+ CFArray& operator=(const CFArray&) = default;
+ CFArray(const CFArray&) = default;
+
+ T& operator[](const SizeT& at)
+ {
+ MUST_PASS(at < this->Count());
+ return fArray[at];
+ }
+
+ Bool Empty()
+ {
+ return this->Count() > 0;
+ }
+
+ const SizeT Capacity()
+ {
+ return N;
+ }
+
+ const SizeT Count()
+ {
+ return N;
+ }
+
+ const T* CData()
+ {
+ return fArray;
+ }
+
+ operator bool()
+ {
+ return !Empty();
+ }
+
+ private:
+ T fArray[N];
+ };
+
+ template <typename ValueType>
+ auto make_list(ValueType val)
+ {
+ return CFArray<ValueType, ARRAY_SIZE(val)>{val};
+ }
+} // namespace Kernel
diff --git a/dev/Usr/LibCF/Property.h b/dev/Usr/LibCF/Property.h
new file mode 100644
index 00000000..629dba27
--- /dev/null
+++ b/dev/Usr/LibCF/Property.h
@@ -0,0 +1,53 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#ifndef CFKIT_PROPS_H
+#define CFKIT_PROPS_H
+
+#include <LibSCI/SCI.h>
+#include <LibCF/Ref.h>
+
+#define kMaxPropLen (256U)
+
+namespace LibCF
+{
+ class CFString;
+ class CFProperty;
+ class CFGUID;
+
+ template<typename Cls, SizeT N>
+ class CFArray;
+
+ /// @brief handle to anything (number, ptr, string...)
+ using CFPropertyId = UIntPtr;
+
+ /// @brief User property class.
+ /// @example /prop/foo or /prop/bar
+ class CFProperty
+ {
+ public:
+ CFProperty();
+ virtual ~CFProperty();
+
+ public:
+ CFProperty& operator=(const CFProperty&) = default;
+ CFProperty(const CFProperty&) = default;
+
+ Bool StringEquals(CFString& name);
+ CFPropertyId& GetValue();
+ CFString& GetKey();
+
+ private:
+ CFString* fName{nullptr};
+ CFPropertyId fValue{0UL};
+ Ref<CFGUID> fGUID{};
+ };
+
+ template <SizeT N>
+ using CFPropertyArray = CFArray<CFProperty, N>;
+} // namespace CFKit
+
+#endif // !CFKIT_PROPS_H
diff --git a/dev/Usr/LibCF/Ref.h b/dev/Usr/LibCF/Ref.h
new file mode 100644
index 00000000..faad67c5
--- /dev/null
+++ b/dev/Usr/LibCF/Ref.h
@@ -0,0 +1,106 @@
+
+/* -------------------------------------------
+
+ Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#ifndef _NEWKIT_REF_H_
+#define _NEWKIT_REF_H_
+
+#include <LibSCI/SCI.h>
+
+namespace LibCF
+{
+ template <typename T>
+ class Ref final
+ {
+ public:
+ Ref() = default;
+
+ ~Ref()
+ {
+ if (MmGetHeapFlags(fClass) != -1)
+ delete fClass;
+ }
+
+ public:
+ Ref(T* cls)
+ : fClass(cls)
+ {
+ }
+
+ Ref(T cls)
+ : fClass(&cls)
+ {
+ }
+
+ Ref& operator=(T ref)
+ {
+ if (!fClass)
+ return *this;
+
+ fClass = &ref;
+ return *this;
+ }
+
+ public:
+ T operator->() const
+ {
+ MUST_PASS(*fClass);
+ return *fClass;
+ }
+
+ T& Leak() noexcept
+ {
+ return *fClass;
+ }
+
+ T& TryLeak() const noexcept
+ {
+ MUST_PASS(*fClass);
+ return *fClass;
+ }
+
+ T operator*()
+ {
+ return *fClass;
+ }
+
+ operator bool() noexcept
+ {
+ return fClass;
+ }
+
+ private:
+ T* fClass{nullptr};
+ };
+
+ template <typename T>
+ class NonNullRef final
+ {
+ public:
+ NonNullRef() = delete;
+ NonNullRef(nullPtr) = delete;
+
+ NonNullRef(T* ref)
+ : fRef(ref)
+ {
+ MUST_PASS(ref);
+ }
+
+ Ref<T>& operator->()
+ {
+ MUST_PASS(fRef);
+ return fRef;
+ }
+
+ NonNullRef& operator=(const NonNullRef<T>& ref) = delete;
+ NonNullRef(const NonNullRef<T>& ref) = default;
+
+ private:
+ Ref<T> fRef{nullptr};
+ };
+} // namespace Kernel
+
+#endif // ifndef _NEWKIT_REF_H_
diff --git a/dev/Usr/LibCompress/API.h b/dev/Usr/LibCompress/API.h
deleted file mode 100644
index 9c3e9fde..00000000
--- a/dev/Usr/LibCompress/API.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
-
-------------------------------------------- */
-
-#ifndef COMPRESSKIT_RLE_H
-#define COMPRESSKIT_RLE_H
-
-#include <External/Defines.h>
-// #include <LibCompress/Exports.h>
-
-namespace Kernel
-{
- class ICompressProxy;
-} // namespace Kernel
-
-#endif // !ifndef COMPRESSKIT_RLE_H
diff --git a/dev/Usr/LibCompress/LCCompress.s b/dev/Usr/LibCompress/LCCompress.s
deleted file mode 100644
index c490bbba..00000000
--- a/dev/Usr/LibCompress/LCCompress.s
+++ /dev/null
@@ -1,7 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2024 Amlal EL Mahrouss, all rights reserved.
-
-------------------------------------------- */
-
-.text \ No newline at end of file
diff --git a/dev/Usr/LibCompress/LCDecompress.s b/dev/Usr/LibCompress/LCDecompress.s
deleted file mode 100644
index c490bbba..00000000
--- a/dev/Usr/LibCompress/LCDecompress.s
+++ /dev/null
@@ -1,7 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2024 Amlal EL Mahrouss, all rights reserved.
-
-------------------------------------------- */
-
-.text \ No newline at end of file
diff --git a/dev/Usr/LibSystem/.keepme b/dev/Usr/LibSystem/.keepme
deleted file mode 100644
index e69de29b..00000000
--- a/dev/Usr/LibSystem/.keepme
+++ /dev/null
diff --git a/dev/Usr/LibWS/.keepme b/dev/Usr/LibWS/.keepme
deleted file mode 100644
index e69de29b..00000000
--- a/dev/Usr/LibWS/.keepme
+++ /dev/null