summaryrefslogtreecommitdiffhomepage
path: root/Public
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-28 22:49:17 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-28 22:50:22 +0100
commit39040dde3a6eef2e9b08ce6d3c5ca23aa4566ce6 (patch)
tree439405d1f2546320d6a2954f952284089acc398d /Public
parent59f1fd3491c91cca9c47e9a7e61d454b685bfb6a (diff)
Public: ZipKit compiles correctly now.
Public: Also Did reworked System APIs. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Public')
-rw-r--r--Public/SDK/SystemKit/CoreAPI.hxx17
-rw-r--r--Public/SDK/SystemKit/FileAPI.hxx41
-rw-r--r--Public/SDK/SystemKit/HeapAPI.hxx68
-rw-r--r--Public/SDK/SystemKit/SystemKit.hxx12
-rw-r--r--Public/SDK/SystemKit/TIB.hxx41
-rw-r--r--Public/SDK/SystemKit/ThreadAPI.hxx42
-rw-r--r--Public/SDK/ZipKit/Defines.hpp5
-rw-r--r--Public/SDK/ZipKit/Makefile19
-rw-r--r--Public/SDK/ZipKit/Zip.cpp86
-rw-r--r--Public/SDK/ZipKit/Zip.cxx80
-rw-r--r--Public/SDK/ZipKit/Zip.hpp45
-rw-r--r--Public/SDK/ZipKit/zconf.hpp2
12 files changed, 302 insertions, 156 deletions
diff --git a/Public/SDK/SystemKit/CoreAPI.hxx b/Public/SDK/SystemKit/CoreAPI.hxx
new file mode 100644
index 00000000..f3e67e96
--- /dev/null
+++ b/Public/SDK/SystemKit/CoreAPI.hxx
@@ -0,0 +1,17 @@
+/*
+ * ========================================================
+ *
+ * h-core
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#pragma once
+
+#ifdef MUST_PASS
+#undef MUST_PASS
+#endif
+
+// unused by user side, it's a kernel thing.
+#define MUST_PASS(e) ((void)e)
diff --git a/Public/SDK/SystemKit/FileAPI.hxx b/Public/SDK/SystemKit/FileAPI.hxx
new file mode 100644
index 00000000..88bf9bfb
--- /dev/null
+++ b/Public/SDK/SystemKit/FileAPI.hxx
@@ -0,0 +1,41 @@
+/*
+ * ========================================================
+ *
+ * h-core
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#ifndef _SYSTEM_KIT_HCORE_FILE_HPP
+#define _SYSTEM_KIT_HCORE_FILE_HPP
+
+#include <CompilerKit/Compiler.hpp>
+#include <NewKit/Defines.hpp>
+
+using namespace hCore;
+
+class MeFile final
+{
+ public:
+ explicit MeFile(const char *path);
+ ~MeFile();
+
+ public:
+ HCORE_COPY_DEFAULT(MeFile);
+
+ public:
+ void *Read(SizeT off, SizeT sz);
+ void Write(void *buf, SizeT off, SizeT sz);
+ void Seek(SizeT off);
+ void *Read(SizeT sz);
+ void Write(void *buf, SizeT sz);
+ void Rewind();
+
+ public:
+ void SetMIME(const char *mime);
+};
+
+typedef MeFile *MeFilePtr;
+
+#endif // ifndef _SYSTEM_KIT_HCORE_FILE_HPP
diff --git a/Public/SDK/SystemKit/HeapAPI.hxx b/Public/SDK/SystemKit/HeapAPI.hxx
new file mode 100644
index 00000000..a1d7f51d
--- /dev/null
+++ b/Public/SDK/SystemKit/HeapAPI.hxx
@@ -0,0 +1,68 @@
+/*
+ * ========================================================
+ *
+ * h-core
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#pragma once
+
+#include <CompilerKit/Compiler.hpp>
+#include <NewKit/Defines.hpp>
+
+using namespace hCore;
+
+class MeMemoryException;
+
+typedef void *MeHeapPtr;
+
+enum
+{
+ kHeapExpandable = 2,
+ kHeapNoExecute = 4,
+ kHeapShared = 6,
+ kHeapReadOnly = 8,
+ kHeapNoFlags = 0
+};
+
+class MeHeap final
+{
+ private:
+ explicit MeHeap();
+
+ public:
+ ~MeHeap();
+
+ public:
+ HCORE_COPY_DEFAULT(MeHeap);
+
+ public:
+ static MeHeap *Shared() noexcept;
+
+ public:
+ void Dispose(MeHeapPtr me) noexcept;
+ SizeT Tell(MeHeapPtr me) noexcept;
+ MeHeapPtr New(const SizeT &sz, const Int32 flags = kHeapNoFlags);
+};
+
+class MeMemoryException final
+{
+ public:
+ MeMemoryException() = default;
+ ~MeMemoryException() = default;
+
+ public:
+ HCORE_COPY_DEFAULT(MeMemoryException);
+
+ public:
+ const char *Name();
+ const char *Reason();
+
+ private:
+ const char *mReason{"Memory error!"};
+
+ private:
+ friend MeHeap;
+};
diff --git a/Public/SDK/SystemKit/SystemKit.hxx b/Public/SDK/SystemKit/SystemKit.hxx
new file mode 100644
index 00000000..9e1443cc
--- /dev/null
+++ b/Public/SDK/SystemKit/SystemKit.hxx
@@ -0,0 +1,12 @@
+/*** ===========================================
+ (C) Mahrouss Logic
+ ===========================================*/
+
+#pragma once
+
+#include <SystemKit/CoreAPI.hxx>
+#include <SystemKit/FileAPI.hxx>
+#include <SystemKit/HeapAPI.hxx>
+#include <SystemKit/ThreadAPI.hxx>
+
+using namespace hCore;
diff --git a/Public/SDK/SystemKit/TIB.hxx b/Public/SDK/SystemKit/TIB.hxx
deleted file mode 100644
index 3a1c038b..00000000
--- a/Public/SDK/SystemKit/TIB.hxx
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-* ========================================================
-*
-* h-core
-* Copyright Mahrouss Logic, all rights reserved.
-*
-* ========================================================
-*/
-
-//
-// Created by Amlal on 1/27/24.
-//
-
-#ifndef HCORE_TIB_HXX
-#define HCORE_TIB_HXX
-
-#include <Private/NewKit/Defines.hpp>
-
-namespace hCore
-{
- /// @brief Thread Information Block for Local Storage.
- /// Located in GS on AMD64, Virtual Address 0x10000 (64x0, 32x0, ARM64)
- struct ThreadInformationBlock final
- {
- const Char TIB_NAME[255]; // Module Name
- const UIntPtr TIB_START; // Start Address
- const UIntPtr TIB_ALLOC; // Allocation Heap
- const UIntPtr TIB_STACK; // Stack Pointer.
- const Int32 TIB_ARCH; // Architecture and/or platform.
- };
-
- enum
- {
- kPC_IA64,
- kPC_ARM,
- kMACS_64x0,
- kMACS_32x0,
- };
-}
-
-#endif // HCORE_TIB_HXX
diff --git a/Public/SDK/SystemKit/ThreadAPI.hxx b/Public/SDK/SystemKit/ThreadAPI.hxx
new file mode 100644
index 00000000..f99da698
--- /dev/null
+++ b/Public/SDK/SystemKit/ThreadAPI.hxx
@@ -0,0 +1,42 @@
+/*
+ * ========================================================
+ *
+ * h-core
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+//
+// Created by Amlal on 1/27/24.
+//
+
+#ifndef __THREAD_API__
+#define __THREAD_API__
+
+#include <NewKit/Defines.hpp>
+
+namespace hCore
+{
+/// @brief Thread Information Block for Local Storage.
+/// Located in GS on AMD64, Virtual Address 0x10000 (64x0, 32x0, ARM64)
+struct ThreadInformationBlock final
+{
+ const Char TIB_NAME[255]; // Module Name
+ const UIntPtr TIB_START; // Start Address
+ const UIntPtr TIB_ALLOC; // Allocation Heap
+ const UIntPtr TIB_STACK; // Stack Pointer.
+ const Int32 TIB_ARCH; // Architecture and/or platform.
+};
+
+enum
+{
+ kPC_IA64,
+ kPC_AMD64 = kPC_IA64,
+ kPC_ARM,
+ kMACS_64x0,
+ kMACS_32x0,
+};
+} // namespace hCore
+
+#endif // __THREAD_API__
diff --git a/Public/SDK/ZipKit/Defines.hpp b/Public/SDK/ZipKit/Defines.hpp
index 8c3790c6..053e3ad5 100644
--- a/Public/SDK/ZipKit/Defines.hpp
+++ b/Public/SDK/ZipKit/Defines.hpp
@@ -9,6 +9,9 @@
#pragma once
-#include <SystemKit/Defines.hpp>
+#include <NewKit/Defines.hpp>
+#include <SystemKit/SystemKit.hxx>
+
+using namespace hCore;
#define ZIPKIT_VERSION "1.0.1"
diff --git a/Public/SDK/ZipKit/Makefile b/Public/SDK/ZipKit/Makefile
index bb1cd69d..ded36b53 100644
--- a/Public/SDK/ZipKit/Makefile
+++ b/Public/SDK/ZipKit/Makefile
@@ -1,5 +1,16 @@
-# (C) Mahrouss Logic, 2024, all rights reserved.
+CC=x86_64-elf-g++
+CCFLAGS=-c -ffreestanding -fno-rtti -fno-exceptions -std=c++20
+ASM=nasm
+ASMFLAGS=-f elf64
-.PHONY: zip
-zip:
- @echo "Later!"
+.PHONY: build_zipkit
+build_zipkit:
+ $(CC) -I../ -I../../../Private/ $(CCFLAGS) *.cxx
+
+.PHONY: all
+all: build_zipkit
+ @echo "Done."
+
+.PHONY: clean
+clean:
+ rm -f *.o
diff --git a/Public/SDK/ZipKit/Zip.cpp b/Public/SDK/ZipKit/Zip.cpp
deleted file mode 100644
index a7b3e0f4..00000000
--- a/Public/SDK/ZipKit/Zip.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * ========================================================
- *
- * h-core
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
-
-#include <ZipKit/Zip.hpp>
-
-#include <SystemKit/MeHeap.hpp>
-#include <SystemKit/MeFile.hpp>
-
-#define kInitialSz 4096
-
-namespace ZipKit
-{
- ZipStream::ZipStream()
- :
- fSharedData(MeHeap::Shared()->New(kInitialSz, kHeapExpandable)),
- fSharedSz(kInitialSz)
- {
-
- }
-
- ZipStream::~ZipStream() noexcept
- {
- if (fSharedData)
- MeHeap::Shared()->Dispose(fSharedData);
- }
-
- MeFilePtr ZipStream::FlushToFile(const char* name)
- {
- MeFilePtr fp = new MeFile(name);
- MUST_PASS(fp);
-
- this->fSharedSz = MeHeap::Shared()->Tell(this->fSharedData);
-
- fp->SetMIME("application/x-bzip");
- fp->Write(this->fSharedData, this->fSharedSz);
-
- return fp;
- }
-
- void* ZipStream::Deflate(const char* name)
- {
- z_stream deflate_stream{ 0 };
-
- deflate_stream.zalloc = Z_NULL;
- deflate_stream.zfree = Z_NULL;
- deflate_stream.opaque = Z_NULL;
-
- // setup "b" as the input and "c" as the compressed output
- deflate_stream.avail_in = (uInt)this->fSharedSz+1; // size of input, string + terminator
- deflate_stream.next_in = (Bytef *)this->fSharedData; // input char array
- deflate_stream.avail_out = (uInt)this->fSharedSz; // size of output
- deflate_stream.next_out = (Bytef *)this->fSharedData; // output char array
-
- deflateInit(deflate_stream);
- deflate(&deflate_stream, Z_NO_FLUSH);
- deflateEnd(&deflate_stream);
-
- return this->fSharedData;
- }
-
- void ZipStream::Inflate(const char* name, void* data)
- {
- z_stream inflate_stream{ 0 };
-
- inflate_stream.zalloc = Z_NULL;
- inflate_stream.zfree = Z_NULL;
- inflate_stream.opaque = Z_NULL;
-
- // setup "b" as the input and "c" as the compressed output
- inflate_stream.avail_in = (uInt)((char*)inflate_stream.next_out - b); // size of input
-
- inflate_stream.next_in = (Bytef *)this->fSharedData; // input char array
- inflate_stream.avail_out = (uInt)this->fSharedSz; // size of output
- inflate_stream.next_out = (Bytef *)this->fSharedData; // output char array
-
- inflateInit(inflate_stream);
- inflate(&inflate_stream, Z_NO_FLUSH);
- inflateEnd(&inflate_stream);
- }
-} \ No newline at end of file
diff --git a/Public/SDK/ZipKit/Zip.cxx b/Public/SDK/ZipKit/Zip.cxx
new file mode 100644
index 00000000..18bf4a0b
--- /dev/null
+++ b/Public/SDK/ZipKit/Zip.cxx
@@ -0,0 +1,80 @@
+/*
+ * ========================================================
+ *
+ * h-core
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#include <ZipKit/Zip.hpp>
+
+// very hacky thing because of gcc...
+#include <SystemKit/CoreAPI.hxx>
+
+#define kInitialSz 4096
+
+namespace ZipKit
+{
+ZipStream::ZipStream() : fSharedData(MeHeap::Shared()->New(kInitialSz, kHeapExpandable)), fSharedSz(kInitialSz)
+{
+}
+
+ZipStream::~ZipStream() noexcept
+{
+ if (fSharedData)
+ MeHeap::Shared()->Dispose(fSharedData);
+}
+
+MeFilePtr ZipStream::FlushToFile(const char *name)
+{
+ MeFilePtr fp = new MeFile(name);
+ MUST_PASS(fp);
+
+ this->fSharedSz = MeHeap::Shared()->Tell(this->fSharedData);
+
+ fp->SetMIME("application/x-bzip");
+ fp->Write(this->fSharedData, this->fSharedSz);
+
+ return fp;
+}
+
+void *ZipStream::Deflate(const char *name)
+{
+ z_stream deflate_stream{0};
+
+ deflate_stream.zalloc = Z_NULL;
+ deflate_stream.zfree = Z_NULL;
+ deflate_stream.opaque = Z_NULL;
+
+ deflate_stream.avail_in = (uInt)this->fSharedSz + 1; // size of input, string + terminator
+ deflate_stream.next_in = (Bytef *)this->fSharedData; // input char array
+ deflate_stream.avail_out = (uInt)this->fSharedSz; // size of output
+ deflate_stream.next_out = (Bytef *)this->fSharedData; // output char array
+
+ deflateInit(&deflate_stream, 1);
+ deflate(&deflate_stream, Z_NO_FLUSH);
+ deflateEnd(&deflate_stream);
+
+ return this->fSharedData;
+}
+
+void ZipStream::Inflate(const char *name, void *data)
+{
+ z_stream inflate_stream{0};
+
+ inflate_stream.zalloc = Z_NULL;
+ inflate_stream.zfree = Z_NULL;
+ inflate_stream.opaque = Z_NULL;
+
+ inflate_stream.avail_in = (SizeT)((char *)(inflate_stream.next_out - (Bytef *)this->fSharedData)); // size of input
+
+ inflate_stream.next_in = (Bytef *)this->fSharedData; // input char array
+ inflate_stream.avail_out = (uInt)this->fSharedSz; // size of output
+ inflate_stream.next_out = (Bytef *)this->fSharedData; // output char array
+
+ inflateInit(&inflate_stream);
+ inflate(&inflate_stream, Z_NO_FLUSH);
+ inflateEnd(&inflate_stream);
+}
+} // namespace ZipKit
diff --git a/Public/SDK/ZipKit/Zip.hpp b/Public/SDK/ZipKit/Zip.hpp
index 72105bc1..601e5ae7 100644
--- a/Public/SDK/ZipKit/Zip.hpp
+++ b/Public/SDK/ZipKit/Zip.hpp
@@ -1,11 +1,11 @@
/*
-* ========================================================
-*
-* h-core
-* Copyright 2024 Mahrouss Logic, all rights reserved.
-*
-* ========================================================
-*/
+ * ========================================================
+ *
+ * h-core
+ * Copyright 2024 Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
#pragma once
@@ -22,24 +22,23 @@ class ZipStream;
class ZipStream final
{
- public:
- explicit ZipStream();
- ~ZipStream() noexcept;
+ public:
+ explicit ZipStream();
+ ~ZipStream() noexcept;
- public:
- HCORE_COPY_DEFAULT(ZipStream);
+ public:
+ HCORE_COPY_DEFAULT(ZipStream);
- public:
- MeFilePtr FlushToFile(const char* name);
- void* Deflate(const char* name);
- void Inflate(const char* name, void* data);
+ public:
+ MeFilePtr FlushToFile(const char *name);
+ void *Deflate(const char *name);
+ void Inflate(const char *name, void *data);
- private:
- VoidStar fSharedData{ nullptr };
- SizeT fSharedSz{ 0 };
-
- private:
- z_stream fStream;
+ private:
+ VoidPtr fSharedData{nullptr};
+ SizeT fSharedSz{0};
+ private:
+ z_stream fStream;
};
-}
+} // namespace ZipKit
diff --git a/Public/SDK/ZipKit/zconf.hpp b/Public/SDK/ZipKit/zconf.hpp
index 571e09e0..0eb08624 100644
--- a/Public/SDK/ZipKit/zconf.hpp
+++ b/Public/SDK/ZipKit/zconf.hpp
@@ -374,7 +374,7 @@
#endif
-#if defined (__h-core__)
+#if defined (__hCore__)
# ifdef ZLIB_DLL
# ifdef ZLIB_INTERNAL
# define ZEXPORT