diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-30 08:05:00 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-30 08:05:00 +0100 |
| commit | f22e69b8837b84548f79e0b8ca7bef24605c6611 (patch) | |
| tree | cda020af66538453cc3d8fb16a41e2e3eec7b01e | |
| parent | a8c17ccd6d97cc78830917dc6282b040b21ba16c (diff) | |
Kernel: Update TODO_LIST.txt, fix CRC32, add .vscode dir in root.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
| -rw-r--r-- | .vscode/c_cpp_properties.json | 17 | ||||
| -rw-r--r-- | Private/Documentation/hCore::Ref.html | 16 | ||||
| -rw-r--r-- | Private/FSKit/NewFSIndexer.hxx | 84 | ||||
| -rw-r--r-- | Private/KernelKit/DriveManager.hpp | 90 | ||||
| -rw-r--r-- | Private/NewKit/CRC32.hpp | 2 | ||||
| -rw-r--r-- | Private/NewKit/Defines.hpp | 29 | ||||
| -rw-r--r-- | Private/NewKit/Json.hpp | 136 | ||||
| -rw-r--r-- | Private/NewKit/KernelHeap.hpp | 11 | ||||
| -rw-r--r-- | Private/Source/Crc32.cxx | 20 | ||||
| -rw-r--r-- | Private/Source/SMPManager.cxx | 6 | ||||
| -rw-r--r-- | Private/Source/ThreadLocalStorage.cxx | 5 | ||||
| -rw-r--r-- | Private/StorageKit/Storage.hpp | 9 | ||||
| -rw-r--r-- | Private/StorageKit/StorageCore.inl | 70 | ||||
| -rw-r--r-- | Public/Documentation/hCore::CWindowLookAndFeel.html | 23 | ||||
| -rw-r--r-- | Public/Tools/.gitkeep | 0 | ||||
| -rw-r--r-- | Public/Tools/MakeNewFS.cxx | 6 | ||||
| -rw-r--r-- | TODO_LIST.TXT | 1 |
17 files changed, 225 insertions, 300 deletions
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..892f41cf --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "HCore", + "includePath": [ + "${workspaceFolder}/Private/**", + "${workspaceFolder}/Private/NewBoot/*", + "${workspaceFolder}/Private/acpiSDK/source/include/*" + ], + "defines": ["__HCORE__", "__HAVE_HCORE_APIS__"], + "cStandard": "c17", + "cppStandard": "c++20", + "intelliSenseMode": "gcc-x64" + } + ], + "version": 4 +} diff --git a/Private/Documentation/hCore::Ref.html b/Private/Documentation/hCore::Ref.html deleted file mode 100644 index 6d5866c9..00000000 --- a/Private/Documentation/hCore::Ref.html +++ /dev/null @@ -1,16 +0,0 @@ -<title>hCore::Ref - HCore documentation.</title> - -<h1>hCore::Ref</h1> - -<ul> - <li>Ref::Ref()</li> - <li>Ref::~Ref()</li> - - <li>Ref::Ref(T cls, const bool& strong = false)</li> - - <li>T operator->() const</li> - <li>T operator*()</li> - <li>operator bool()</li> - <li>bool IsStrong() const</li> - <li>T& Leak()</li> -</ul> diff --git a/Private/FSKit/NewFSIndexer.hxx b/Private/FSKit/NewFSIndexer.hxx index c5f63059..66a73db4 100644 --- a/Private/FSKit/NewFSIndexer.hxx +++ b/Private/FSKit/NewFSIndexer.hxx @@ -12,49 +12,43 @@ #include <FSKit/IndexableProperty.hxx> #include <NewKit/MutableArray.hpp> -namespace hCore -{ - namespace Indexer - { - class INewFSIterator; - - using IndexElement = voidPtr; - - /// - /// @name INewFSIterator - /// @brief Stores relevant information for file indexing. - /// - - class INewFSIterator - { - public: - INewFSIterator() = default; - virtual ~INewFSIterator() = default; - - public: - HCORE_COPY_DEFAULT(INewFSIterator); - - public: - void Add(IndexableProperty& indexProp) { fProps.Add(indexProp); } - - void Remove(const SizeT& indexProp) { fProps.Remove(indexProp); } - - Boolean FindLinear(IndexProperty& filters) - { - for (size_t i = 0; i < fProps.Count(); ++i) - { - if (StringBuilder::Equals(fProps[i].Leak().LeakProperty().Path, filters.Path)) - { - return i; - } - } - - return 0; - } - - private: - MutableArray<IndexableProperty> fProps; - - }; +namespace hCore { +namespace Indexer { +class INewFSIterator; + +using IndexElement = voidPtr; + +/// +/// @name INewFSIterator +/// @brief Stores relevant information for file indexing. +/// + +class INewFSIterator { + public: + INewFSIterator() = default; + virtual ~INewFSIterator() = default; + + public: + HCORE_COPY_DEFAULT(INewFSIterator); + + public: + void Add(IndexableProperty& indexProp) { fProps.Add(indexProp); } + + void Remove(const SizeT& indexProp) { fProps.Remove(indexProp); } + + Boolean FindLinear(IndexProperty& filters) { + for (size_t i = 0; i < fProps.Count(); ++i) { + if (StringBuilder::Equals(fProps[i].Leak().LeakProperty().Path, + filters.Path)) { + return i; + } } -}
\ No newline at end of file + + return 0; + } + + private: + MutableArray<IndexableProperty> fProps; +}; +} // namespace Indexer +} // namespace hCore diff --git a/Private/KernelKit/DriveManager.hpp b/Private/KernelKit/DriveManager.hpp index 3d77dd56..251453aa 100644 --- a/Private/KernelKit/DriveManager.hpp +++ b/Private/KernelKit/DriveManager.hpp @@ -10,52 +10,47 @@ #pragma once #include <CompilerKit/Compiler.hpp> +#include <KernelKit/Device.hpp> #include <NewKit/Defines.hpp> #include <NewKit/String.hpp> -#include <KernelKit/Device.hpp> - #define kDriveInvalidID -1 #define kDriveNameLen 32 -namespace hCore -{ -enum -{ - kInvalidDrive = -1, - kBlockDevice = 0xAD, - kMassStorage = 0xDA, - kFloppyDisc = 0xCD, - kOpticalDisc = 0xDC, // CD-ROM/DVD-ROM/Blu-Ray - kReadOnly = 0x10, // Read only drive - kEPMDrive = 0x11, // Explicit Partition Map. - kEPTDrive = 0x12, // ESP w/ EPM partition. - kMBRDrive = 0x13, // IBM PC classic partition scheme +namespace hCore { +enum { + kInvalidDrive = -1, + kBlockDevice = 0xAD, + kMassStorage = 0xDA, + kFloppyDisc = 0xCD, + kOpticalDisc = 0xDC, // CD-ROM/DVD-ROM/Blu-Ray + kReadOnly = 0x10, // Read only drive + kEPMDrive = 0x11, // Explicit Partition Map. + kEPTDrive = 0x12, // ESP w/ EPM partition. + kMBRDrive = 0x13, // IBM PC classic partition scheme }; typedef Int64 DriveID; // Mounted drive. -struct DriveTraits final -{ - char fName[kDriveNameLen]; // /system, /boot... - Int32 fKind; // fMassStorage, fFloppy, fOpticalDisc. - DriveID fId; // Drive id. - Int32 fFlags; // fReadOnly, fXPMDrive, fXPTDrive - - //! disk mount, unmount operations - void (*fMount)(void); - void (*fUnmount)(void); - - bool (*fReady)(void); //! is drive ready? - - //! for StorageKit. - struct DrivePacket final - { - voidPtr fPacketContent; // packet body. - Char fPacketMime[32]; //! identify what we're sending. - SizeT fPacketSize; // packet size - } fPacket; +struct DriveTraits final { + char fName[kDriveNameLen]; // /System, /Boot, /USBDevice... + Int32 fKind; // fMassStorage, fFloppy, fOpticalDisc. + DriveID fId; // Drive id. + Int32 fFlags; // fReadOnly, fXPMDrive, fXPTDrive + + //! disk mount, unmount operations + void (*fMount)(void); + void (*fUnmount)(void); + + bool (*fReady)(void); //! is drive ready? + + //! for StorageKit. + struct DrivePacket final { + voidPtr fPacketContent; // packet body. + Char fPacketMime[32]; //! identify what we're sending. + SizeT fPacketSize; // packet size + } fPacket; }; #define kPacketBinary "file/x-binary" @@ -67,20 +62,19 @@ struct DriveTraits final typedef DeviceInterface<DriveTraits> Drive; typedef Drive *DrivePtr; -class DriveSelector final -{ - public: - explicit DriveSelector(); - ~DriveSelector(); +class DriveSelector final { + public: + explicit DriveSelector(); + ~DriveSelector(); - public: - HCORE_COPY_DEFAULT(DriveSelector); + public: + HCORE_COPY_DEFAULT(DriveSelector); - DriveTraits &GetMounted(); - bool Mount(DriveTraits *drive); - DriveTraits *Unmount(); + DriveTraits &GetMounted(); + bool Mount(DriveTraits *drive); + DriveTraits *Unmount(); - private: - DriveTraits *fDrive; + private: + DriveTraits *fDrive; }; -} // namespace hCore +} // namespace hCore diff --git a/Private/NewKit/CRC32.hpp b/Private/NewKit/CRC32.hpp index 751f98b9..85be87e4 100644 --- a/Private/NewKit/CRC32.hpp +++ b/Private/NewKit/CRC32.hpp @@ -15,7 +15,7 @@ #define kCrcCnt (256) namespace hCore { -Int ke_crc32(const Char* crc, Int len); +Int ke_calculate_crc32(const Char* crc, Int len) noexcept; } // namespace hCore #endif // !__CRC32_H__ diff --git a/Private/NewKit/Defines.hpp b/Private/NewKit/Defines.hpp index 50668376..7d674df3 100644 --- a/Private/NewKit/Defines.hpp +++ b/Private/NewKit/Defines.hpp @@ -23,8 +23,7 @@ #endif #endif -namespace hCore -{ +namespace hCore { using voidPtr = void *; using VoidPtr = void *; using nullPtr = decltype(nullptr); @@ -67,25 +66,23 @@ using Void = void; using Lba = SSizeT; -enum class Endian : UChar -{ - kLittle, - kBig -}; +enum class Endian : UChar { kLittle, kBig }; -template <typename Args> Args &&forward(Args &arg) -{ - return static_cast<Args &&>(arg); +template <typename Args> +Args &&forward(Args &arg) { + return static_cast<Args &&>(arg); } -template <typename Args> Args &&move(Args &&arg) -{ - return static_cast<Args &&>(arg); +template <typename Args> +Args &&move(Args &&arg) { + return static_cast<Args &&>(arg); } -} // namespace hCore +} // namespace hCore -#define DEDUCE_ENDIAN(address, value) \ - (((reinterpret_cast<hCore::Char *>(address)[0]) == (value)) ? (hCore::Endian::kBig) : (hCore::Endian::kLittle)) +#define DEDUCE_ENDIAN(address, value) \ + (((reinterpret_cast<hCore::Char *>(address)[0]) == (value)) \ + ? (hCore::Endian::kBig) \ + : (hCore::Endian::kLittle)) #define Yes (true) #define No (false) diff --git a/Private/NewKit/Json.hpp b/Private/NewKit/Json.hpp index 7c1a85e4..d4d42ab1 100644 --- a/Private/NewKit/Json.hpp +++ b/Private/NewKit/Json.hpp @@ -10,104 +10,80 @@ #pragma once -// last-rev: 5/11/23 +// last-rev: 30/01/24 +#include <CompilerKit/Compiler.hpp> #include <NewKit/Defines.hpp> #include <NewKit/Stream.hpp> #include <NewKit/String.hpp> #include <NewKit/Utils.hpp> -#include <CompilerKit/Compiler.hpp> +namespace hCore { +class JsonType final { + public: + explicit JsonType() : hCore::JsonType(1, 1) {} -namespace hCore -{ -class JsonType final -{ - public: - explicit JsonType() : hCore::JsonType(1, 1) - { - } + explicit JsonType(SizeT lhsLen, SizeT rhsLen) + : fKey(lhsLen), fValue(rhsLen) {} - explicit JsonType(SizeT lhsLen, SizeT rhsLen) : fKey(lhsLen), fValue(rhsLen) - { - } + ~JsonType() = default; - ~JsonType() = default; + HCORE_COPY_DEFAULT(JsonType); - HCORE_COPY_DEFAULT(JsonType); + private: + StringView fKey; + StringView fValue; - private: - StringView fKey; - StringView fValue; + public: + StringView &AsKey() { return fKey; } - public: - StringView &AsKey() - { - return fKey; - } + StringView &AsValue() { return fValue; } - StringView &AsValue() - { - return fValue; - } - - static JsonType kUndefined; + static JsonType kUndefined; }; -struct JsonStreamTraits final -{ - JsonType In(const char *full_array) - { - SizeT len = string_length(full_array); - - if (full_array[0] == '\"' && full_array[len - 1] == ',' || full_array[len - 1] == '\"') - { - Boolean probe_key = true; - - SizeT key_len = 0; - SizeT value_len = 0; - - for (SizeT i = 1; i < len; i++) - { - if (full_array[i] == ' ') - continue; - - JsonType type(255, 255); - - if (probe_key) - { - type.AsKey().Data()[key_len] = full_array[i]; - ++key_len; - - if (full_array[i] == '\"') - { - probe_key = false; - type.AsKey().Data()[key_len] = 0; - - ++i; - } - } - else - { - type.AsValue().Data()[value_len] = full_array[i]; - ++value_len; - - if (full_array[i] == '\"') - { - type.AsValue().Data()[value_len] = 0; - } - } - } - } +struct JsonStreamTraits final { + JsonType In(const char *full_array) { + SizeT len = string_length(full_array); - return JsonType::kUndefined; - } + if (full_array[0] == '\"' && full_array[len - 1] == ',' || + full_array[len - 1] == '\"') { + Boolean probe_key = true; - JsonType Out(JsonType &out) - { - return out; + SizeT key_len = 0; + SizeT value_len = 0; + + for (SizeT i = 1; i < len; i++) { + if (full_array[i] == ' ') continue; + + JsonType type(255, 255); + + if (probe_key) { + type.AsKey().Data()[key_len] = full_array[i]; + ++key_len; + + if (full_array[i] == '\"') { + probe_key = false; + type.AsKey().Data()[key_len] = 0; + + ++i; + } + } else { + type.AsValue().Data()[value_len] = full_array[i]; + ++value_len; + + if (full_array[i] == '\"') { + type.AsValue().Data()[value_len] = 0; + } + } + } } + + return JsonType::kUndefined; + } + + JsonType Out(JsonType &out) { return out; } }; using JsonStream = Stream<JsonStreamTraits, JsonType>; -} // namespace hCore +} // namespace hCore diff --git a/Private/NewKit/KernelHeap.hpp b/Private/NewKit/KernelHeap.hpp index 13037aa1..301a2294 100644 --- a/Private/NewKit/KernelHeap.hpp +++ b/Private/NewKit/KernelHeap.hpp @@ -9,15 +9,14 @@ #pragma once -// last-rev 5/03/23 +// last-rev 30/01/24 // file: KHeap.hpp // description: heap allocation for the kernel. #include <NewKit/Defines.hpp> #include <NewKit/Pmm.hpp> -namespace hCore -{ - Int32 kernel_delete_ptr(voidPtr allocatedPtr); - voidPtr kernel_new_ptr(const SizeT &sz, const bool rw, const bool user); -} // namespace hCore +namespace hCore { +Int32 kernel_delete_ptr(voidPtr allocatedPtr); +voidPtr kernel_new_ptr(const SizeT &sz, const bool rw, const bool user); +} // namespace hCore diff --git a/Private/Source/Crc32.cxx b/Private/Source/Crc32.cxx index e711626d..233d9847 100644 --- a/Private/Source/Crc32.cxx +++ b/Private/Source/Crc32.cxx @@ -58,21 +58,13 @@ UInt kCrcTbl[kCrcCnt] = { 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d}; -static Int crc_byte(Int crc, UChar byte) { - crc = (crc >> 8) ^ - kCrcTbl[(byte) ^ (crc & 0x000000FF)]; // shift 8 bytes to the right +/// @brief calculate CRC32 of series of byte. +Int ke_calculate_crc32(const Char *p, Int len) noexcept { + UInt32 crc = 0xffffffff; - // XOR polynomial XOR the crc - // without the 2 highest bytes - return crc; -} - -Int ke_crc32(const Char *byte, Int len) noexcept { - Int checksum = 0; - - for (UChar index = 1; index < len; ++index) - checksum = crc_byte(checksum, byte[index]); + while (len-- != 0) crc = kCrcTbl[((UInt8)crc ^ *(p++))] ^ (crc >> 8); - return checksum; + // return (~crc); also works + return (crc ^ 0xffffffff); } } // namespace hCore diff --git a/Private/Source/SMPManager.cxx b/Private/Source/SMPManager.cxx index 05e47ea8..c261e6b8 100644 --- a/Private/Source/SMPManager.cxx +++ b/Private/Source/SMPManager.cxx @@ -121,9 +121,9 @@ bool SMPManager::Switch(HAL::StackFrame* stack) { } /** - * Index hart - * @param idx - * @return + * Index Hardware thread + * @param idx the index + * @return the reference to the hardware thread. */ Ref<ProcessorCore> SMPManager::operator[](const SizeT& idx) { return m_ThreadList[idx].Leak(); diff --git a/Private/Source/ThreadLocalStorage.cxx b/Private/Source/ThreadLocalStorage.cxx index 66ec69d6..4e322e81 100644 --- a/Private/Source/ThreadLocalStorage.cxx +++ b/Private/Source/ThreadLocalStorage.cxx @@ -10,6 +10,11 @@ #include <KernelKit/ProcessManager.hpp> #include <KernelKit/ThreadLocalStorage.hxx> +/***********************************************************************************/ +/// @file ThreadLocalStorage.cxx +/// @brief TLS implementation in kernel. +/***********************************************************************************/ + using namespace hCore; /** diff --git a/Private/StorageKit/Storage.hpp b/Private/StorageKit/Storage.hpp index 8b3670af..568a9d25 100644 --- a/Private/StorageKit/Storage.hpp +++ b/Private/StorageKit/Storage.hpp @@ -10,19 +10,14 @@ #pragma once #include <NewKit/Defines.hpp> - #include <StorageKit/ATA.hpp> #include <StorageKit/NVME.hpp> -#include <StorageKit/StorageCore.inl> - typedef hCore::UInt16 OSScsiPacket[12]; extern const OSScsiPacket kCDRomPacketTemplate; -#define f_kDriveSectorSize 2048 +#define f_kDriveSectorSize 512 #define f_kDriveSize(last_lba) ((last_lba + 1) * f_kDriveSectorSize) - - - +#include <StorageKit/StorageCore.inl> diff --git a/Private/StorageKit/StorageCore.inl b/Private/StorageKit/StorageCore.inl index 85e2a3f5..73e89a9d 100644 --- a/Private/StorageKit/StorageCore.inl +++ b/Private/StorageKit/StorageCore.inl @@ -6,51 +6,39 @@ * * ======================================================== */ - + #ifndef __STORAGEKIT_STORAGECORE_INL__ #define __STORAGEKIT_STORAGECORE_INL__ #include <NewKit/Defines.hpp> -// @brief Storage management unit. -// swap files, files, dirs optimization. - -namespace hCore -{ - typedef Char* SKStr; - - //! @brief Storage context, reads and write file according to the descriptor layout. - class StorageContext - { - public: - explicit StorageContext() = default; - ~StorageContext() = default; - - StorageContext& operator=(const StorageContext&) = default; - StorageContext(const StorageContext&) = default; - - public: - bool Write(VoidPtr fileDescriptor, SizeT sizeFileDescriptor); - - struct SDescriptor - { - VoidPtr fFilePtr; - SizeT fFilePtrSz; - }; - - SDescriptor Read(const SKStr name); - - }; - -#define kMaxPathSK 4096 - - struct StorageLayout final - { - Char fName[kMaxPathSK]; - VoidPtr fData; - SizeT fDataSz; - Int32 fType; - }; -} +/// @file StorageCore.inl +/// @brief Storage Management API. + +namespace hCore { +typedef Char* SKStr; + +///! @brief Storage context, reads and write file according to the descriptor +///! layout. +class StorageContext { + public: + explicit StorageContext() = default; + ~StorageContext() = default; + + StorageContext& operator=(const StorageContext&) = default; + StorageContext(const StorageContext&) = default; + + public: + bool Write(VoidPtr fileDescriptor, SizeT sizeFileDescriptor); + + struct PacketDescriptor final { + VoidPtr fFilePtr; + SizeT fFilePtrSz; + }; + + PacketDescriptor* Read(const SKStr name); + Int32 Write(PacketDescriptor* packet, const SKStr name); +}; +} // namespace hCore #endif /* ifndef __STORAGEKIT_STORAGECORE_INL__ */ diff --git a/Public/Documentation/hCore::CWindowLookAndFeel.html b/Public/Documentation/hCore::CWindowLookAndFeel.html deleted file mode 100644 index 36ff1dc6..00000000 --- a/Public/Documentation/hCore::CWindowLookAndFeel.html +++ /dev/null @@ -1,23 +0,0 @@ -<title> - hCore::CWindowLookAndFeel - hCore documentation. -</title> - -<h1> - hCore::CWindowLookAndFeel -</h1> - -<ul> - <li>CWindowLookAndFeel::CWindowLookAndFeel()</li> - <li>CWindowLookAndFeel::~CWindowLookAndFeel()</li> - - <li>virtual bool DrawButton(const char* label, Int32 x, Int32 y, Int32 w, Int32 h) = 0;</li> - <li>virtual bool DrawButtonHovered(const char* label, Int32 x, Int32 y, Int32 w, Int32 h) = 0;</li> - <li>virtual bool DrawRadio(const bool enable, Int32 x, Int32 y) = 0;</li> - - <li>virtual bool DrawCheckbox(const bool enable, Int32 x, Int32 y) = 0;</li> - <li>virtual bool DrawTextBox(const char* content, Int32 x, Int32 y, Int32 w, Int32 h) = 0;</li> - <li>virtual bool DrawWindow(const char* title, Int32 x, Int32 y, Int32 w, Int32 h) = 0;</li> - <li>virtual bool DrawWindowFocused(const char* title, Int32 x, Int32 y, Int32 w, Int32 h) = 0;</li> - <li>virtual bool DrawGroupBox(const char* title) = 0;</li> - <li>virtual bool DrawCursor(Int32 x, Int32 y, Int32 type) = 0;</li> -</ul> diff --git a/Public/Tools/.gitkeep b/Public/Tools/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Public/Tools/.gitkeep diff --git a/Public/Tools/MakeNewFS.cxx b/Public/Tools/MakeNewFS.cxx new file mode 100644 index 00000000..d4d28e6d --- /dev/null +++ b/Public/Tools/MakeNewFS.cxx @@ -0,0 +1,6 @@ +/***********************************************************************************/ +/// @file MakeNewFS.cxx +/// @brief NewFS partition program. +/***********************************************************************************/ + +int main() { return 0; } diff --git a/TODO_LIST.TXT b/TODO_LIST.TXT index 54bece13..f8e1da3e 100644 --- a/TODO_LIST.TXT +++ b/TODO_LIST.TXT @@ -7,4 +7,5 @@ - Load kernel into memory [ ] - Jump to kernel [ ] - Context switch x87/SSE/AVX registers [ ] +- Framebuffer and ATA support [ ] - Native Subsystem and GUI [ ] |
