summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-04-06 22:28:21 +0200
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-04-06 22:28:59 +0200
commit256e54f04323215a6b4e964e3955c606563c2dae (patch)
tree7720038b93b7a6e99cb750249a2667b857209d51
parente2fd9a88d6b9def2fdebbc974001ae0778c26622 (diff)
NewOS: Pre-release R1, see below.
NewFS: Add FindFork, improve CreateFork, still working on NewFS support. DriveManager: Fix ke_drv_input and ke_drv_output, drv_std_ calls, throws an error when no specifying any drive backends. Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
-rw-r--r--.vscode/c_cpp_properties.json4
-rw-r--r--Meta/NewKernel.svg48
-rw-r--r--Private/FSKit/NewFS.hxx8
-rw-r--r--Private/Source/DriveManager.cxx13
-rw-r--r--Private/Source/FS/NewFS.cxx183
-rw-r--r--Private/Source/ThreadLocalStorage.cxx6
-rw-r--r--ReadMe.md7
7 files changed, 163 insertions, 106 deletions
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index cb5e3f38..c6d63a65 100644
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -15,7 +15,7 @@
"__HAVE_MAHROUSS_APIS__",
"__FSKIT_NEWFS__",
"__EFI_x86_64__",
- "__AHCI__"
+ "__ATA_PIO__"
],
"cStandard": "c17",
"cppStandard": "c++20",
@@ -47,7 +47,7 @@
"__HAVE_MAHROUSS_APIS__",
"__FSKIT_NEWFS__",
"__EFI_x86_64__",
- "__AHCI__"
+ "__ATA_PIO__"
],
"cStandard": "c17",
"cppStandard": "c++20",
diff --git a/Meta/NewKernel.svg b/Meta/NewKernel.svg
index 863dcc0a..cfa820ba 100644
--- a/Meta/NewKernel.svg
+++ b/Meta/NewKernel.svg
@@ -1,29 +1,27 @@
-<svg width="98" height="98" viewBox="0 0 98 98" fill="none" xmlns="http://www.w3.org/2000/svg">
-<rect width="98" height="98" rx="10" fill="url(#paint0_linear_139_17)"/>
-<path d="M89 49L49 9H79C84.5228 9 89 13.4772 89 19V49Z" fill="url(#paint1_linear_139_17)"/>
-<path d="M49 49L9 9H49V49Z" fill="url(#paint2_linear_139_17)"/>
-<path d="M9 49L49 89H19C13.4772 89 9 84.5228 9 79V49Z" fill="url(#paint3_linear_139_17)"/>
-<path d="M49 49L89 89H49V49Z" fill="url(#paint4_linear_139_17)"/>
+<svg width="61" height="61" viewBox="0 0 61 61" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect x="1" y="1" width="59" height="59" rx="9" fill="#302929" fill-opacity="0.7" stroke="#323232" stroke-width="2"/>
+<g filter="url(#filter0_d_0_1)">
+<circle cx="30.5" cy="30.5" r="17.5" fill="url(#paint0_angular_0_1)"/>
+<circle cx="30.5" cy="30.5" r="18.5" stroke="url(#paint1_linear_0_1)" stroke-width="2"/>
+</g>
<defs>
-<linearGradient id="paint0_linear_139_17" x1="49" y1="0" x2="49" y2="98" gradientUnits="userSpaceOnUse">
-<stop stop-color="#767A7F"/>
-<stop offset="1" stop-color="#232A31"/>
-</linearGradient>
-<linearGradient id="paint1_linear_139_17" x1="69" y1="9" x2="69" y2="49" gradientUnits="userSpaceOnUse">
-<stop stop-color="#0075FF"/>
-<stop offset="1" stop-color="#004699"/>
-</linearGradient>
-<linearGradient id="paint2_linear_139_17" x1="29" y1="9" x2="29" y2="49" gradientUnits="userSpaceOnUse">
-<stop stop-color="#0075FF"/>
-<stop offset="1" stop-color="#004699"/>
-</linearGradient>
-<linearGradient id="paint3_linear_139_17" x1="29" y1="89" x2="29" y2="49" gradientUnits="userSpaceOnUse">
-<stop stop-color="#0075FF"/>
-<stop offset="1" stop-color="#004699"/>
-</linearGradient>
-<linearGradient id="paint4_linear_139_17" x1="69" y1="89" x2="69" y2="49" gradientUnits="userSpaceOnUse">
-<stop stop-color="#0075FF"/>
-<stop offset="1" stop-color="#004699"/>
+<filter id="filter0_d_0_1" x="7" y="11" width="47" height="47" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
+<feFlood flood-opacity="0" result="BackgroundImageFix"/>
+<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
+<feOffset dy="4"/>
+<feGaussianBlur stdDeviation="2"/>
+<feComposite in2="hardAlpha" operator="out"/>
+<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
+<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_0_1"/>
+<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_0_1" result="shape"/>
+</filter>
+<radialGradient id="paint0_angular_0_1" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(30.5 30.5) rotate(90) scale(17.5)">
+<stop stop-color="#D33333"/>
+<stop offset="1" stop-color="#BF1B1B"/>
+</radialGradient>
+<linearGradient id="paint1_linear_0_1" x1="30.5" y1="13" x2="30.5" y2="48" gradientUnits="userSpaceOnUse">
+<stop stop-color="#E23E3E"/>
+<stop offset="1" stop-color="#992626"/>
</linearGradient>
</defs>
</svg>
diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx
index 04e68cc6..3d5071c5 100644
--- a/Private/FSKit/NewFS.hxx
+++ b/Private/FSKit/NewFS.hxx
@@ -188,7 +188,11 @@ class NewFSParser final {
/// @return the fork
_Output NewFork* CreateFork(_Input NewCatalog* catalog, _Input NewFork& theFork);
- virtual _Output NewFork* FindFork(_Input NewCatalog* catalog, _Input const Char* name) = 0;
+ /// @brief Find fork inside New filesystem.
+ /// @param catalog the catalog.
+ /// @param name the fork name.
+ /// @return the fork.
+ _Output NewFork* FindFork(_Input NewCatalog* catalog, _Input const Char* name);
virtual _Output Void RemoveFork(_Input NewFork* fork) = 0;
@@ -228,7 +232,7 @@ class NewFSParser final {
/// @brief Make a EPM+NewFS drive out of the disk.
/// @param drive The drive to write on.
/// @return If it was sucessful, see DbgLastError().
- virtual bool Format(_Input _Output DriveTrait* drive) = 0;
+ bool Format(_Input _Output DriveTrait* drive);
public:
Int32 fDriveIndex{ kNewFSSubDriveA };
diff --git a/Private/Source/DriveManager.cxx b/Private/Source/DriveManager.cxx
index b468ebae..45b3c09a 100644
--- a/Private/Source/DriveManager.cxx
+++ b/Private/Source/DriveManager.cxx
@@ -7,6 +7,7 @@
#include <KernelKit/DebugOutput.hpp>
#include <KernelKit/DriveManager.hxx>
#include <Builtins/ATA/Defines.hxx>
+#include <Builtins/AHCI/Defines.hxx>
/// @file DriveManager.cxx
/// @brief Kernel drive manager.
@@ -25,10 +26,10 @@ Void ke_drv_input(DriveTrait::DrivePacket* pckt) {
pckt->fPacketGood = false;
-#ifndef __AHCI__
- drv_std_read(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize);
-#else
+#ifdef __AHCI__
drv_std_read(pckt->fLba, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize);
+#elif defined(__ATA_PIO__) || defined(__ATA_DMA__)
+ drv_std_read(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize);
#endif
@@ -45,10 +46,10 @@ Void ke_drv_output(DriveTrait::DrivePacket* pckt) {
pckt->fPacketGood = false;
-#ifndef __AHCI__
- drv_std_write(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize);
-#else
+#ifdef __AHCI__
drv_std_write(pckt->fLba,(Char*)pckt->fPacketContent, 1, pckt->fPacketSize);
+#elif defined(__ATA_PIO__) || defined(__ATA_DMA__)
+ drv_std_write(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize);
#endif
pckt->fPacketGood = true;
diff --git a/Private/Source/FS/NewFS.cxx b/Private/Source/FS/NewFS.cxx
index f497c2af..3c33f441 100644
--- a/Private/Source/FS/NewFS.cxx
+++ b/Private/Source/FS/NewFS.cxx
@@ -11,9 +11,9 @@
using namespace NewOS;
-STATIC Lba ke_find_fork(SizeT sz);
-STATIC Lba ke_find_catalog(SizeT sz);
-STATIC Lba ke_find_data(SizeT sz);
+STATIC Lba ke_find_free_fork(SizeT sz);
+STATIC Lba ke_find_free_catalog(SizeT sz);
+STATIC Lba ke_find_free_data(SizeT sz);
STATIC MountpointInterface sMountpointInterface;
@@ -21,72 +21,121 @@ STATIC MountpointInterface sMountpointInterface;
/// @param catalog it's catalog
/// @param theFork the fork itself.
/// @return the fork
-_Output NewFork* NewFSParser::CreateFork(_Input NewCatalog* catalog, _Input NewFork& theFork)
-{
- if (catalog &&
- theFork.Name[0] != 0 &&
- theFork.DataSize > 0) {
- Lba whereFork = 0;
-
- theFork.DataOffset = ke_find_fork(theFork.DataSize);
- theFork.Flags |= kNewFSFlagCreated;
-
- if (catalog->FirstFork == 0) {
- catalog->FirstFork = whereFork;
- } else {
- if (catalog->LastFork == 0) {
- theFork.PreviousSibling = catalog->FirstFork;
- }
- }
-
- if (catalog->LastFork == 0) {
- catalog->LastFork = whereFork;
- } else {
- theFork.PreviousSibling = catalog->LastFork;
- }
-
- if (!sMountpointInterface.GetAddressOf(this->fDriveIndex) ||
- !*sMountpointInterface.GetAddressOf(this->fDriveIndex))
- return nullptr;
-
- auto drv = *sMountpointInterface.GetAddressOf(this->fDriveIndex);
-
- drv->fPacket.fLba = whereFork;
- drv->fPacket.fPacketSize = theFork.DataSize;
- drv->fPacket.fPacketContent = (VoidPtr)&theFork;
-
- rt_copy_memory((VoidPtr)"fs/newfs-packet", drv->fPacket.fPacketMime, 16);
-
- if (auto res = fs_newfs_write(&sMountpointInterface, *drv, this->fDriveIndex);
- res) {
- switch (res)
- {
- case 1:
- DbgLastError() = kErrorDiskReadOnly;
- break;
- case 2:
- DbgLastError() = kErrorDiskIsFull;
- break;
- DbgLastError() = kErrorNoSuchDisk;
- break;
-
- default:
- break;
- }
- return nullptr;
- }
-
- /// Also update catalog.
- this->WriteCatalog(catalog, nullptr);
-
- return &theFork;
+_Output NewFork* NewFSParser::CreateFork(_Input NewCatalog* catalog,
+ _Input NewFork& theFork) {
+ if (catalog && theFork.Name[0] != 0 && theFork.DataSize > 0) {
+ Lba whereFork = 0;
+
+ theFork.DataOffset = ke_find_free_fork(theFork.DataSize);
+ theFork.Flags |= kNewFSFlagCreated;
+
+ if (catalog->FirstFork == 0) {
+ catalog->FirstFork = whereFork;
+ } else {
+ if (catalog->LastFork == 0) {
+ theFork.PreviousSibling = catalog->FirstFork;
+ }
}
- return nullptr;
+ if (catalog->LastFork == 0) {
+ catalog->LastFork = whereFork;
+ } else {
+ theFork.PreviousSibling = catalog->LastFork;
+ }
+
+ if (!sMountpointInterface.GetAddressOf(this->fDriveIndex) ||
+ !*sMountpointInterface.GetAddressOf(this->fDriveIndex))
+ return nullptr;
+
+ auto drv = *sMountpointInterface.GetAddressOf(this->fDriveIndex);
+
+ drv->fPacket.fLba = whereFork;
+ drv->fPacket.fPacketSize = theFork.DataSize;
+ drv->fPacket.fPacketContent = (VoidPtr)&theFork;
+
+ rt_copy_memory((VoidPtr) "fs/newfs-packet", drv->fPacket.fPacketMime, 16);
+
+ if (auto res =
+ fs_newfs_write(&sMountpointInterface, *drv, this->fDriveIndex);
+ res) {
+ switch (res) {
+ case 1:
+ DbgLastError() = kErrorDiskReadOnly;
+ break;
+ case 2:
+ DbgLastError() = kErrorDiskIsFull;
+ break;
+ DbgLastError() = kErrorNoSuchDisk;
+ break;
+
+ default:
+ break;
+ }
+ return nullptr;
+ }
+
+ /// Also update catalog.
+ this->WriteCatalog(catalog, nullptr);
+
+ return &theFork;
+ }
+
+ return nullptr;
+}
+
+/// @brief Find fork inside New filesystem.
+/// @param catalog the catalog.
+/// @param name the fork name.
+/// @return the fork.
+_Output NewFork* NewFSParser::FindFork(_Input NewCatalog* catalog,
+ _Input const Char* name) {
+ auto drv = *sMountpointInterface.GetAddressOf(this->fDriveIndex);
+ NewFork* theFork = nullptr;
+ Lba lba = catalog->FirstFork;
+
+ while (lba != 0) {
+ drv->fPacket.fLba = lba;
+ drv->fPacket.fPacketSize = sizeof(NewFork);
+ drv->fPacket.fPacketContent = (VoidPtr)theFork;
+
+ rt_copy_memory((VoidPtr) "fs/newfs-packet", drv->fPacket.fPacketMime, 16);
+
+ if (auto res =
+ fs_newfs_read(&sMountpointInterface, *drv, this->fDriveIndex);
+ res) {
+ switch (res) {
+ case 1:
+ DbgLastError() = kErrorDiskReadOnly;
+ break;
+ case 2:
+ DbgLastError() = kErrorDiskIsFull;
+ break;
+ DbgLastError() = kErrorNoSuchDisk;
+ break;
+
+ default:
+ break;
+ }
+ return nullptr;
+ }
+
+ if (StringBuilder::Equals(theFork->Name, name)) {
+ break;
+ }
+
+ lba = theFork->NextSibling;
+ }
+
+ return theFork;
}
-STATIC Lba ke_find_fork(SizeT sz) {}
-STATIC Lba ke_find_catalog(SizeT sz) {}
-STATIC Lba ke_find_data(SizeT sz) {}
+/// @brief Make a EPM+NewFS drive out of the disk.
+/// @param drive The drive to write on.
+/// @return If it was sucessful, see DbgLastError().
+bool NewFSParser::Format(_Input _Output DriveTrait* drive) { return false; }
+
+STATIC Lba ke_find_free_fork(SizeT sz) { return 0; }
+STATIC Lba ke_find_free_catalog(SizeT sz) { return 0; }
+STATIC Lba ke_find_free_data(SizeT sz) { return 0; }
-#endif // ifdef __FSKIT_NEWFS__ \ No newline at end of file
+#endif // ifdef __FSKIT_NEWFS__ \ No newline at end of file
diff --git a/Private/Source/ThreadLocalStorage.cxx b/Private/Source/ThreadLocalStorage.cxx
index 2bc0e298..d3e31a1c 100644
--- a/Private/Source/ThreadLocalStorage.cxx
+++ b/Private/Source/ThreadLocalStorage.cxx
@@ -20,7 +20,7 @@
using namespace NewOS;
/**
- * Check for cookie inside TIB.
+ * @brief Check for cookie inside TIB.
* @param tib the TIB to check.
* @return if the cookie is enabled.
*/
@@ -38,8 +38,8 @@ Boolean tls_check_tib(ThreadInformationBlock* tib) {
}
/**
- * System call implementation of the TLS check.
- * @param ptr
+ * @brief System call implementation of the TLS check.
+ * @param stackPtr The call frame.
* @return
*/
EXTERN_C Void tls_check_syscall_impl(NewOS::HAL::StackFramePtr stackPtr) noexcept {
diff --git a/ReadMe.md b/ReadMe.md
index abce2004..641391b0 100644
--- a/ReadMe.md
+++ b/ReadMe.md
@@ -1,4 +1,9 @@
-# NewKernel
+<div align="center">
+<img src="Meta/NewKernel.svg" width="96" height="96"/>
+<h1>NewKernel</h1>
+</div>
+
+<br>
You need: