summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-28 20:54:33 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-28 20:54:33 +0100
commitb2c7b8604ed3a4c209a15a9ffd718a43163dd9b4 (patch)
tree851d79e3a9b1c676b48ec8dfcd2b989f4da45c9b
parent215518ae55a54973a1ae18f572ca5bf0ac2a499e (diff)
NewKernel: Add PowerPC partition type inside EPM, add Leak() FileStream method. and documentation.
SystemLib: Start implementing the API. Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
-rw-r--r--Private/FSKit/NewFS.hxx18
-rw-r--r--Private/FirmwareKit/EPM.hxx4
-rw-r--r--Private/KernelKit/FileManager.hpp46
-rw-r--r--Private/Source/NewFS+FileManager.cxx2
-rw-r--r--Private/StorageKit/AHCI.hpp21
-rw-r--r--Private/StorageKit/ATA.hpp43
-rw-r--r--Private/StorageKit/Storage.hpp2
-rw-r--r--Private/StorageKit/StorageCore.inl41
-rw-r--r--Public/Developer/System.Core/Headers/Defines.h27
-rw-r--r--Public/Developer/System.Core/Headers/File.h33
-rw-r--r--Public/Developer/System.Core/Headers/Heap.h28
-rw-r--r--Public/Developer/System.Core/Headers/TrueType.h2
-rw-r--r--Public/Developer/System.Core/Headers/Window.h54
-rw-r--r--Public/Developer/System.Core/Makefile2
-rw-r--r--Public/Developer/System.Core/Sources/App.c20
-rw-r--r--Public/Developer/System.Core/Sources/Heap.c22
-rw-r--r--Public/Developer/System.Core/Sources/New+Delete.cxx13
-rw-r--r--Public/Developer/System.Core/Sources/Start.c (renamed from Public/Developer/System.Core/Sources/CRT0.c)2
-rw-r--r--Public/Developer/System.Core/Sources/Window.c62
19 files changed, 304 insertions, 138 deletions
diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx
index 43596d62..6b852f73 100644
--- a/Private/FSKit/NewFS.hxx
+++ b/Private/FSKit/NewFS.hxx
@@ -171,17 +171,21 @@ class NewFSParser {
HCORE_COPY_DEFAULT(NewFSParser);
public:
- virtual void CreateFork(_Input NewCatalog& catalog, _Input NewFork& theFork) = 0;
+ virtual _Output NewFork* CreateFork(_Input NewCatalog* catalog, _Input NewFork& theFork) = 0;
- virtual _Output NewFork* FindFork(_Input NewCatalog& catalog, _Input const Char* name) = 0;
+ virtual _Output NewFork* FindFork(_Input NewCatalog* catalog, _Input const Char* name) = 0;
+
+ virtual _Output Void RemoveFork(_Input NewFork* fork) = 0;
+
+ virtual _Output Void CloseFork(_Input NewFork* fork) = 0;
virtual _Output NewCatalog* FindCatalog(const char* catalogName) = 0;
virtual _Output NewCatalog* RootCatalog() = 0;
- virtual _Output NewCatalog* NextCatalog(_Input _Output NewCatalog& cur) = 0;
+ virtual _Output NewCatalog* NextCatalog(_Input _Output NewCatalog* cur) = 0;
- virtual _Output NewCatalog* PrevCatalog(_Input _Output NewCatalog& cur) = 0;
+ virtual _Output NewCatalog* PrevCatalog(_Input _Output NewCatalog* cur) = 0;
virtual _Output NewCatalog* GetCatalog(_Input const char* name) = 0;
@@ -191,15 +195,15 @@ class NewFSParser {
virtual _Output NewCatalog* CreateCatalog(_Input const char* name) = 0;
- virtual bool WriteCatalog(_Input _Output NewCatalog& catalog,
+ virtual bool WriteCatalog(_Input _Output NewCatalog* catalog,
voidPtr data) = 0;
- virtual bool RemoveCatalog(_Input _Output NewCatalog& catalog) = 0;
+ virtual bool RemoveCatalog(_Input _Output NewCatalog* catalog) = 0;
/// @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;
+ virtual bool Format(_Input _Output DriveTrait* drive) = 0;
};
///
diff --git a/Private/FirmwareKit/EPM.hxx b/Private/FirmwareKit/EPM.hxx
index 5657fb06..34346a97 100644
--- a/Private/FirmwareKit/EPM.hxx
+++ b/Private/FirmwareKit/EPM.hxx
@@ -71,6 +71,10 @@ struct PACKED PartitionBlock {
#define kEPMMagic32k "EPM32"
+/* @brief PowerPC magic for EPM */
+
+#define kEPMMagicPPC "EPMPC"
+
/* @brief Invalid magic for EPM */
#define kEPMMagicError "EPM??"
diff --git a/Private/KernelKit/FileManager.hpp b/Private/KernelKit/FileManager.hpp
index 1ce8d629..9f7249cd 100644
--- a/Private/KernelKit/FileManager.hpp
+++ b/Private/KernelKit/FileManager.hpp
@@ -38,6 +38,7 @@
/// refer to first enum.
#define kFileOpsCount 4
+#define kFileMimeGeneric "application-type/*"
namespace NewOS {
enum {
@@ -63,8 +64,17 @@ class FilesystemManagerInterface {
HCORE_COPY_DEFAULT(FilesystemManagerInterface);
public:
- static bool Mount(FilesystemManagerInterface *pMount);
+ /// @brief Mounts a new filesystem into an active state.
+ /// @param interface the filesystem interface
+ /// @return
+ static bool Mount(FilesystemManagerInterface *interface);
+
+ /// @brief Unmounts the active filesystem
+ /// @return
static FilesystemManagerInterface *Unmount();
+
+ /// @brief Getter, gets the active filesystem.
+ /// @return
static FilesystemManagerInterface *GetMounted();
public:
@@ -79,8 +89,10 @@ class FilesystemManagerInterface {
virtual NodePtr Open(_Input const char *path, _Input const char *r) = 0;
public:
- virtual void Write(_Input NodePtr node, _Input VoidPtr data, _Input Int32 flags) = 0;
- virtual _Output VoidPtr Read(_Input NodePtr node, _Input Int32 flags, _Input SizeT sz) = 0;
+ virtual Void Write(_Input NodePtr node, _Input VoidPtr data,
+ _Input Int32 flags) = 0;
+ virtual _Output VoidPtr Read(_Input NodePtr node, _Input Int32 flags,
+ _Input SizeT sz) = 0;
public:
virtual bool Seek(_Input NodePtr node, _Input SizeT off) = 0;
@@ -95,7 +107,8 @@ class FilesystemManagerInterface {
#ifdef __FSKIT_NEWFS__
/**
- * @brief Based of FilesystemManagerInterface, takes care of managing NewFS disks.
+ * @brief Based of FilesystemManagerInterface, takes care of managing NewFS
+ * disks.
*/
class NewFilesystemManager final : public FilesystemManagerInterface {
public:
@@ -127,6 +140,12 @@ class NewFilesystemManager final : public FilesystemManagerInterface {
this->Write(node, data, flags);
}
+ public:
+ /**
+ * NOTE: Write and Read are implemented using a custom NodePtr, retrieved
+ * using OpenFork.
+ */
+
VoidPtr Read(NodePtr node, Int32 flags, SizeT sz) override {
return this->Read(node, flags, sz);
}
@@ -162,7 +181,8 @@ class NewFilesystemManager final : public FilesystemManagerInterface {
* @tparam Encoding file encoding (char, wchar_t...)
* @tparam FSClass Filesystem contract who takes care of it.
*/
-template <typename Encoding = char, typename FSClass = FilesystemManagerInterface>
+template <typename Encoding = char,
+ typename FSClass = FilesystemManagerInterface>
class FileStream final {
public:
explicit FileStream(const Encoding *path, const Encoding *restrict_type);
@@ -210,7 +230,7 @@ class FileStream final {
return nullptr;
}
- void Write(SizeT offset, voidPtr data, SizeT sz) {
+ Void Write(SizeT offset, voidPtr data, SizeT sz) {
auto man = FSClass::GetMounted();
if (man) {
@@ -219,21 +239,25 @@ class FileStream final {
}
}
+ /// @brief Leak node pointer.
+ /// @return The node pointer.
+ NodePtr Leak() { return fFile; }
+
public:
char *MIME() noexcept { return const_cast<char *>(fMime); }
private:
NodePtr fFile;
- const Char *fMime{"application-type/*"};
+ const Char *fMime{kFileMimeGeneric};
};
-#define kRestrictRW "r+"
-#define kRestrictRWB "r+b"
#define kRestrictR "r"
#define kRestrictRB "rb"
+#define kRestrictW "w"
+#define kRestrictRW "rw"
-using FileStreamUTF8 = FileStream<char>;
-using FileStreamUTF16 = FileStream<wchar_t>;
+using FileStreamUTF8 = FileStream<Char>;
+using FileStreamUTF16 = FileStream<WideChar>;
typedef UInt64 CursorType;
diff --git a/Private/Source/NewFS+FileManager.cxx b/Private/Source/NewFS+FileManager.cxx
index 2b5abf27..171f0c6f 100644
--- a/Private/Source/NewFS+FileManager.cxx
+++ b/Private/Source/NewFS+FileManager.cxx
@@ -20,7 +20,7 @@ bool NewFilesystemManager::Remove(const char* node_name) {
if (node_name == nullptr || *node_name == 0) return false;
if (auto catalog = fImpl->GetCatalog(node_name); catalog)
- return fImpl->RemoveCatalog(*catalog);
+ return fImpl->RemoveCatalog(catalog);
return false;
}
diff --git a/Private/StorageKit/AHCI.hpp b/Private/StorageKit/AHCI.hpp
index 20cddf3f..6f5b5a90 100644
--- a/Private/StorageKit/AHCI.hpp
+++ b/Private/StorageKit/AHCI.hpp
@@ -14,8 +14,9 @@ class AHCIPacket;
class AHCIDeviceInterface : public DeviceInterface<AHCIPacket> {
public:
- explicit AHCIDeviceInterface(void (*Out)(AHCIPacket outpacket),
- void (*In)(AHCIPacket inpacket), void (*Cleanup)(void));
+ explicit AHCIDeviceInterface(void (*Out)(AHCIPacket outpacket),
+ void (*In)(AHCIPacket inpacket),
+ void (*Cleanup)(void));
virtual ~AHCIDeviceInterface();
@@ -25,16 +26,18 @@ class AHCIDeviceInterface : public DeviceInterface<AHCIPacket> {
const char *Name() const override;
- private:
+ private:
+ void (*fOut)(AHCIPacket);
+ void (*fIn)(AHCIPacket);
void (*fCleanup)(void);
};
class AHCIPacket final {
UIntPtr DataPtr;
- SizeT DataSz;
- UInt8 PortId;
- UInt8 PortRdy;
- Lba Begin;
- Lba End;
+ SizeT DataSz;
+ UInt8 PortId;
+ UInt8 PortRdy;
+ Lba BeginLba;
+ Lba SectorCnt;
};
-} // namespace NewOS \ No newline at end of file
+} // namespace NewOS \ No newline at end of file
diff --git a/Private/StorageKit/ATA.hpp b/Private/StorageKit/ATA.hpp
new file mode 100644
index 00000000..5ad5a2d4
--- /dev/null
+++ b/Private/StorageKit/ATA.hpp
@@ -0,0 +1,43 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+#include <KernelKit/DeviceManager.hpp>
+#include <NewKit/OwnPtr.hpp>
+
+namespace NewOS {
+class ATAPacket;
+
+class ATADeviceInterface : public DeviceInterface<ATAPacket> {
+ public:
+ explicit ATADeviceInterface(void (*Out)(ATAPacket outpacket),
+ void (*In)(ATAPacket inpacket),
+ void (*Cleanup)(void));
+
+ virtual ~ATADeviceInterface();
+
+ public:
+ ATADeviceInterface &operator=(const ATADeviceInterface &) = default;
+ ATADeviceInterface(const ATADeviceInterface &) = default;
+
+ 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/Storage.hpp b/Private/StorageKit/Storage.hpp
index 6654c62b..8e7614e6 100644
--- a/Private/StorageKit/Storage.hpp
+++ b/Private/StorageKit/Storage.hpp
@@ -20,5 +20,3 @@ extern const SKScsiPacket kCDRomPacketTemplate;
#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
deleted file mode 100644
index 8a7ca0b9..00000000
--- a/Private/StorageKit/StorageCore.inl
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
-
-#ifndef __STORAGEKIT_STORAGECORE_INL__
-#define __STORAGEKIT_STORAGECORE_INL__
-
-#include <NewKit/Defines.hpp>
-
-/// @file StorageCore.inl
-/// @brief Storage Management API.
-
-namespace NewOS {
-typedef Char* SKStr;
-
-///! @brief Storage context, reads and write file according to the descriptor
-///layout.
-class StorageInterface {
- public:
- explicit StorageInterface() = default;
- virtual ~StorageInterface() = default;
-
- StorageInterface& operator=(const StorageInterface&) = default;
- StorageInterface(const StorageInterface&) = default;
-
- public:
- struct PacketDescriptor final {
- VoidPtr fFilePtr;
- SizeT fFilePtrSz;
- Lba fBase;
- UInt32 fDriveId;
- };
-
- virtual PacketDescriptor* Read(const SKStr name) = 0;
- virtual Int32 Write(PacketDescriptor* packet, const SKStr name) = 0;
-};
-} // namespace NewOS
-
-#endif /* ifndef __STORAGEKIT_STORAGECORE_INL__ */
diff --git a/Public/Developer/System.Core/Headers/Defines.h b/Public/Developer/System.Core/Headers/Defines.h
index cf8cbde6..36884786 100644
--- a/Public/Developer/System.Core/Headers/Defines.h
+++ b/Public/Developer/System.Core/Headers/Defines.h
@@ -82,7 +82,7 @@ typedef CharacterTypeUTF8 BooleanType;
#define CA_PTR *
-#define CA_UNREFERENCED_PARAMETER(e) ((VoidType)e)
+#define CA_UNREFERENCED_PARAMETER(e) ((VoidType)(e))
#ifdef __x86_64__
@@ -124,16 +124,22 @@ typedef CharacterTypeUTF8 BooleanType;
#endif // __cplusplus
enum RtProcessCall {
- kProcessCallAllocPtr = 1,
- kProcessCallFreePtr,
- kProcessCallSizePtr,
- kProcessCallCheckPtr,
- kProcessCallAllocStack,
+ kCallAllocPtr = 1,
+ kCallFreePtr,
+ kCallSizePtr,
+ kCallCheckPtr,
+ kCallAllocStack,
/// @brief Open a specific handle (can be used as sel to call methods related to it.)
- kProcessCallOpenHandle,
- kProcessCallCloseHandle,
+ kCallOpenFile,
+ kCallCloseFile,
+ kCallCreateWindow,
+ kCallCloseWindow,
+ kCallCreateMenu,
+ kCallCloseMenu,
+ kCallGetArgsCount,
+ kCallGetArgsPtr,
/// @brief Number of process calls.
- kProcessCallsCount = 7,
+ kCallsCount,
};
#include <System.Core/Headers/Hint.h>
@@ -193,3 +199,6 @@ CA_EXTERN_C CharacterTypeUTF8* RtGetAppArgumentsPtr(VoidType);
CA_INLINE ObjectRef kApplicationObject;
typedef CharacterTypeUTF8 Str255Type[255];
+
+#define True 1
+#define False 0
diff --git a/Public/Developer/System.Core/Headers/File.h b/Public/Developer/System.Core/Headers/File.h
index bd1d8d3f..13bc7a00 100644
--- a/Public/Developer/System.Core/Headers/File.h
+++ b/Public/Developer/System.Core/Headers/File.h
@@ -9,3 +9,36 @@
#include <System.Core/Headers/Defines.h>
/// @brief Filesystem wrapper.
+
+typedef QWordTyp FSRef;
+
+/// @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);
+
+/// @brief Closes the file and flushes it to the said file.
+/// @param refFs the filesystem reference.
+/// @return
+CA_EXTERN_C VoidType FsCloseFile(FSRef refFs);
+
+typedef QWordTyp FSForkRef;
+
+/// @brief A fork information header.
+typedef struct _Fork {
+ PtrVoidType forkData;
+ SizeType forkSize;
+ Int32Type forkFlags;
+ Int32Type forkKind;
+ CharacterTypeUTF8 forkName[256];
+} ForkType;
+
+/// @brief Gets the fork inside a file.
+/// @param refFs the filesystem ref
+/// @param forkName the fork's name
+/// @return the fork data.
+CA_EXTERN_C FSForkRef FsGetFork(FSRef refFs, const CharacterTypeUTF8* forkName);
+
+#define FsGetDataFork(refFs) FsGetFork(refFs, "data")
+#define FsGetRsrcFork(refFs) FsGetFork(refFs, "rsrc")
diff --git a/Public/Developer/System.Core/Headers/Heap.h b/Public/Developer/System.Core/Headers/Heap.h
index 90f15aa5..9f3215db 100644
--- a/Public/Developer/System.Core/Headers/Heap.h
+++ b/Public/Developer/System.Core/Headers/Heap.h
@@ -15,18 +15,24 @@ enum RtAllocationKind {
kArrayAllocation = 0xD,
};
-/// @brief Allocates a new heap from process pool.
-/// @param refObj
-/// @param sz
-/// @param flags
+/// @brief Allocates a new pointer from process pool.
+/// @param sz the size
+/// @param flags the allocation flags.
/// @return
-CA_EXTERN_C PtrVoidType RtAllocateProcessHeap(ObjectRef refObj, QWordType sz,
+CA_EXTERN_C PtrVoidType RtAllocateProcessPtr(QWordType sz,
DWordType flags);
-/// @brief Check if pointer exists.
-/// @param refObj
-/// @param ptr
+/// @brief Check if the pointer exists.
+/// @param ptr the pointer to free.
/// @return
-CA_EXTERN_C BooleanType RtProcessHeapExists(ObjectRef refObj, PtrVoidType ptr);
-CA_EXTERN_C QWordType RtProcessHeapSize(ObjectRef refObj, PtrVoidType ptr);
-CA_EXTERN_C VoidType RtFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr);
+CA_EXTERN_C BooleanType RtProcessPtrExists(PtrVoidType ptr);
+
+/// @brief Gets the size of the process' pointer.
+/// @param ptr the pointer to free.
+/// @return
+CA_EXTERN_C QWordType RtProcessPtrSize(PtrVoidType ptr);
+
+/// @brief Frees the process pointer.
+/// @param ptr the pointer to free.
+/// @return
+CA_EXTERN_C VoidType RtFreeProcessPtr(PtrVoidType ptr);
diff --git a/Public/Developer/System.Core/Headers/TrueType.h b/Public/Developer/System.Core/Headers/TrueType.h
index 3859148f..2e8f4142 100644
--- a/Public/Developer/System.Core/Headers/TrueType.h
+++ b/Public/Developer/System.Core/Headers/TrueType.h
@@ -23,7 +23,7 @@ typedef QWordType TTFFontRef;
/// @brief Loads a new font into app's memory.
/// @param name
/// @return
-CA_EXTERN_C TTFFontRef FnCreateFont(const char* name);
+CA_EXTERN_C TTFFontRef FnCreateFont(const CharacterTypeUTF8* name);
/// @brief Dispose an allocated font.
/// @param fon
diff --git a/Public/Developer/System.Core/Headers/Window.h b/Public/Developer/System.Core/Headers/Window.h
index 831c87bb..714ef7de 100644
--- a/Public/Developer/System.Core/Headers/Window.h
+++ b/Public/Developer/System.Core/Headers/Window.h
@@ -48,11 +48,19 @@ typedef struct _WindowPort {
WmPoint windowSize;
BooleanType windowInvalidate;
DWordType windowClearColor;
- WordType menuPort;
- WordType parentPort;
- DCRef windowDeviceContext;
+ struct _WindowPort* menuPort;
+ struct _WindowPort* parentPort;
} WindowPort;
+typedef struct _ControlPort {
+ WordType controlPort;
+ WordType controlKind;
+ BooleanType controlVisible;
+ BooleanType controlMoving;
+ WmPoint controlPosition;
+ WindowPort* parentPort;
+} ControlPort;
+
typedef UInt32Type ColorRef;
/***********************************************************************************/
@@ -69,59 +77,57 @@ const ColorRef kRgbWhite = 0xFFFFFFFF;
/// Color macro.
/***********************************************************************************/
-#define RGB32(R, G, B) (ColorRef)(0x##R##G##B)
-
-#define kGraphicsKindWindow 0
-#define kGraphicsKindDialog 1
-#define kGraphicsKindMenu 2
-#define kGraphicsKindButton 3
-#define kGraphicsKindLabel 4
-#define kGraphicsKindDropdown 5
-#define kGraphicsKindIcon 6
-#define kGraphicsKindRadio 7
-#define kGraphicsKindCheck 7
+#define WmMakeColorRef(R, G, B) (ColorRef)(0x##R##G##B)
-typedef QWordType ControlRef;
+#define kControlKindWindow 0
+#define kControlKindDialog 1
+#define kControlKindMenu 2
+#define kControlKindButton 3
+#define kControlKindLabel 4
+#define kControlKindDropdown 5
+#define kControlKindIcon 6
+#define kControlKindRadio 7
+#define kControlKindCheck 7
/// @brief Creates a new control
/// @param id the control rsrc fork.
/// @return
-CA_EXTERN_C ControlRef WmCreateControl(const DWordType id);
+CA_EXTERN_C ControlPort* WmCreateControl(DWordType id);
/// @brief Releases the control
/// @param id the control ref.
/// @return
-CA_EXTERN_C VoidType WmReleaseControl(const ControlRef id);
+CA_EXTERN_C VoidType WmReleaseControl(ControlPort* id);
-/// @brief Moves a control inside a WindowPort.
+/// @brief Moves a control inside a ControlPort.
/// @param id the control ref.
/// @param where where to move at.
/// @return
-CA_EXTERN_C Int32Type WmSetControlPosition(const ControlRef id, WmPoint where);
+CA_EXTERN_C Int32Type WmSetControlPosition(ControlPort* id, WmPoint where);
/// @brief Enable control.
/// @param id
/// @param enabled
/// @return
-CA_EXTERN_C Int32Type WmSetControlEnabled(const ControlRef id, BooleanType enabled);
+CA_EXTERN_C Int32Type WmSetControlEnabled(ControlPort* id, BooleanType enabled);
/// @brief Make control visible.
/// @param id
/// @param visible
/// @return
-CA_EXTERN_C Int32Type WmMakeControlVisible(const ControlRef id, BooleanType visible);
+CA_EXTERN_C Int32Type WmMakeControlVisible(ControlPort* id, BooleanType visible);
/// @brief Creates a new window.
/// @param name the window name
/// @param rsrcId the window fork rsrc id.
/// @return the window graphics port.
-CA_EXTERN_C WindowPort* WmCreateWindow(const char* name, const DWordType rsrcId);
+CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name, const DWordType rsrcId);
/// @brief Creates a new menu
/// @param name the menu's name
/// @param rsrcId the menu fork rsrc id.
/// @return the menu graphics port.
-CA_EXTERN_C WindowPort* WmCreateMenu(const char* name, const DWordType rsrcId);
+CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name, const DWordType rsrcId);
/// @brief Releases the window.
/// @param port the window port.
@@ -137,7 +143,7 @@ CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* port);
/// @param id the gfx port.
/// @param where to move.
/// @return error code.
-CA_EXTERN_C Int32Type WmMoveWindow(const WindowPort* id, WmPoint where);
+CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* id, WmPoint where);
enum {
kWmErrIncompatible = 0x74,
diff --git a/Public/Developer/System.Core/Makefile b/Public/Developer/System.Core/Makefile
index 32b473f3..34851e99 100644
--- a/Public/Developer/System.Core/Makefile
+++ b/Public/Developer/System.Core/Makefile
@@ -10,7 +10,7 @@ OUTPUT=SystemLib.lib
.PHONY: build-core-amd64
build-core-amd64:
- $(CC) $(INC) $(CCFLAGS) $(wildcard Sources/*.c) $(wildcard Sources/*.cxx) $(wildcard AMD64/*.s) -o $(OUTPUT)
+ $(CC) $(CCINC) $(CCFLAGS) $(wildcard Sources/*.c) $(wildcard Sources/*.cxx) $(wildcard AMD64/*.s) -o $(OUTPUT)
.PHONY: all
all: build-core-amd64
diff --git a/Public/Developer/System.Core/Sources/App.c b/Public/Developer/System.Core/Sources/App.c
new file mode 100644
index 00000000..0bd7fd03
--- /dev/null
+++ b/Public/Developer/System.Core/Sources/App.c
@@ -0,0 +1,20 @@
+/** ===========================================
+ (C) Mahrouss Logic
+ ===========================================*/
+
+#include <System.Core/Headers/Defines.h>
+
+/// @brief Gets the app arguments count.
+/// @param
+/// @return
+CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) {
+ return kApplicationObject->Invoke(kApplicationObject, kCallGetArgsCount);
+}
+
+/// @brief Gets the app arguments pointer.
+/// @param
+/// @return
+CA_EXTERN_C CharacterTypeUTF8* RtGetAppArgumentsPtr(VoidType) {
+ return (CharacterTypeUTF8*)kApplicationObject->Invoke(kApplicationObject,
+ kCallGetArgsPtr);
+} \ No newline at end of file
diff --git a/Public/Developer/System.Core/Sources/Heap.c b/Public/Developer/System.Core/Sources/Heap.c
index 390ae072..db4a16bf 100644
--- a/Public/Developer/System.Core/Sources/Heap.c
+++ b/Public/Developer/System.Core/Sources/Heap.c
@@ -7,40 +7,36 @@
#include <System.Core/Headers/Heap.h>
/// @brief Allocate from the user's heap.
-/// @param refObj Process object.
/// @param sz size of object.
/// @param flags flags.
/// @return
-CA_EXTERN_C PtrVoidType RtAllocateProcessHeap(ObjectRef refObj, QWordType sz,
- DWordType flags) {
+CA_EXTERN_C PtrVoidType RtAllocateProcessPtr(QWordType sz,
+ DWordType flags) {
CA_MUST_PASS(sz);
CA_MUST_PASS(flags);
- return (PtrVoidType)refObj->Invoke(refObj, kProcessCallAllocPtr, sz, flags);
+ return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, kCallAllocPtr, sz, flags);
}
/// @brief Free pointer from the user's heap.
-/// @param refObj Process object.
/// @param ptr the pointer to free.
-CA_EXTERN_C VoidType RtFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr) {
+CA_EXTERN_C VoidType RtFreeProcessPtr(PtrVoidType ptr) {
CA_MUST_PASS(ptr);
- CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr));
+ CA_UNREFERENCED_PARAMETER(kApplicationObject->Invoke(kApplicationObject, kCallFreePtr, ptr));
}
/// @brief Get pointer size.
-/// @param refObj Process object.
/// @param ptr the pointer to find.
/// @return the size.
-CA_EXTERN_C QWordType RtProcessHeapSize(ObjectRef refObj, PtrVoidType ptr) {
+CA_EXTERN_C QWordType RtProcessPtrSize(PtrVoidType ptr) {
CA_MUST_PASS(ptr);
- return refObj->Invoke(refObj, kProcessCallSizePtr, ptr);
+ return kApplicationObject->Invoke(kApplicationObject, kCallSizePtr, ptr);
}
/// @brief Check if the pointer exists.
-/// @param refObj Process object.
/// @param ptr the pointer to check.
/// @return if it exists
-CA_EXTERN_C BooleanType RtProcessHeapExists(ObjectRef refObj, PtrVoidType ptr) {
+CA_EXTERN_C BooleanType RtProcessPtrExists(PtrVoidType ptr) {
CA_MUST_PASS(ptr);
- return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr);
+ return kApplicationObject->Invoke(kApplicationObject, kCallCheckPtr, ptr);
}
diff --git a/Public/Developer/System.Core/Sources/New+Delete.cxx b/Public/Developer/System.Core/Sources/New+Delete.cxx
index 3e2942c5..0800da22 100644
--- a/Public/Developer/System.Core/Sources/New+Delete.cxx
+++ b/Public/Developer/System.Core/Sources/New+Delete.cxx
@@ -11,31 +11,30 @@ typedef SizeType size_t;
void* operator new[](size_t sz) {
if (sz == 0) ++sz;
- return RtAllocateProcessHeap(kApplicationObject, sz, kStandardAllocation);
+ return RtAllocateProcessPtr(sz, kStandardAllocation);
}
void* operator new(size_t sz) {
if (sz == 0) ++sz;
- return RtAllocateProcessHeap(kApplicationObject, sz, kArrayAllocation);
+ return RtAllocateProcessPtr(sz, kArrayAllocation);
}
void operator delete[](void* ptr) {
if (ptr == nullptr) return;
- RtFreeProcessHeap(kApplicationObject, ptr);
+ RtFreeProcessPtr(ptr);
}
void operator delete(void* ptr) {
if (ptr == nullptr) return;
- RtFreeProcessHeap(kApplicationObject, ptr);
+ RtFreeProcessPtr(ptr);
}
void operator delete(void* ptr, size_t sz) {
if (ptr == nullptr) return;
+ CA_UNREFERENCED_PARAMETER(sz);
- (void)sz;
-
- RtFreeProcessHeap(kApplicationObject, ptr);
+ RtFreeProcessPtr(ptr);
}
diff --git a/Public/Developer/System.Core/Sources/CRT0.c b/Public/Developer/System.Core/Sources/Start.c
index 03aa62b8..25a29e18 100644
--- a/Public/Developer/System.Core/Sources/CRT0.c
+++ b/Public/Developer/System.Core/Sources/Start.c
@@ -11,4 +11,4 @@ CA_EXTERN_C DWordType __start(VoidType) {
CA_MUST_PASS(kApplicationObject);
return 0;
-} \ No newline at end of file
+}
diff --git a/Public/Developer/System.Core/Sources/Window.c b/Public/Developer/System.Core/Sources/Window.c
new file mode 100644
index 00000000..2b589402
--- /dev/null
+++ b/Public/Developer/System.Core/Sources/Window.c
@@ -0,0 +1,62 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <System.Core/Headers/Window.h>
+
+/// invalid resource handle, they always start from 1.
+#define kInvalidRsrc 0
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name,
+ const DWordType rsrcId) {
+ CA_MUST_PASS(name);
+ CA_MUST_PASS(rsrcId != kInvalidRsrc);
+
+ return (WindowPort*)kApplicationObject->Invoke(
+ kApplicationObject, kCallCreateWindow, name, rsrcId);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C VoidType WmReleaseWindow(WindowPort* winPort) {
+ CA_MUST_PASS(winPort);
+
+ kApplicationObject->Invoke(kApplicationObject, kCallCloseWindow, winPort);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name,
+ const DWordType rsrcId) {
+ CA_MUST_PASS(name);
+ CA_MUST_PASS(rsrcId != kInvalidRsrc);
+
+ return (WindowPort*)kApplicationObject->Invoke(kApplicationObject,
+ kCallCreateMenu, name, rsrcId);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* winPort) {
+ CA_MUST_PASS(winPort);
+
+ kApplicationObject->Invoke(kApplicationObject, kCallCloseMenu, winPort);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* id, WmPoint where) {
+ if (!id) {
+ return kWmErrInvalidArg;
+ }
+
+ id->windowPosition.X = where.X;
+ id->windowPosition.Y = where.Y;
+ id->windowMoving = True;
+
+ return 0;
+} \ No newline at end of file