From d562c97291a69d1ce73e89ba300209a49d419173 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 28 Mar 2024 22:49:49 +0100 Subject: Extend Swap HD from 4MIB to 16MIB, Made SystemLib purely C, added SystemCxxLib for that occasion. Update Framebuffer include to define the color utils inside the C++ source file. Signed-off-by: Amlal El Mahrouss --- Private/KernelKit/Framebuffer.hpp | 10 +++--- Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx | 4 +-- Private/Source/Framebuffer.cxx | 8 +++++ Public/Developer/System.Core/Headers/Defines.h | 5 ++- Public/Developer/System.Core/Headers/Window.h | 10 +++--- Public/Developer/System.Core/Makefile | 18 +++++----- .../Developer/System.Core/Sources/New+Delete.cxx | 40 ---------------------- Public/Developer/System.Core/Sources/Start.c | 7 ++-- Public/Developer/System.Core/Sources/Window.c | 10 +++++- Public/Developer/System.Cxx/.gitkeep | 0 Public/Developer/System.Cxx/Sources/New+Delete.cxx | 27 +++++++++++++++ 11 files changed, 74 insertions(+), 65 deletions(-) delete mode 100644 Public/Developer/System.Core/Sources/New+Delete.cxx create mode 100644 Public/Developer/System.Cxx/.gitkeep create mode 100644 Public/Developer/System.Cxx/Sources/New+Delete.cxx diff --git a/Private/KernelKit/Framebuffer.hpp b/Private/KernelKit/Framebuffer.hpp index d399f382..91b4e8fd 100644 --- a/Private/KernelKit/Framebuffer.hpp +++ b/Private/KernelKit/Framebuffer.hpp @@ -70,11 +70,11 @@ class Framebuffer final { /// Color utils. /***********************************************************************************/ -const UInt32 kRgbRed = 0x000000FF; -const UInt32 kRgbGreen = 0x0000FF00; -const UInt32 kRgbBlue = 0x00FF0000; -const UInt32 kRgbBlack = 0x00000000; -const UInt32 kRgbWhite = 0xFFFFFFFF; +extern const UInt32 kRgbRed; +extern const UInt32 kRgbGreen; +extern const UInt32 kRgbBlue; +extern const UInt32 kRgbBlack; +extern const UInt32 kRgbWhite; } // namespace NewOS /***********************************************************************************/ diff --git a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx index da8e6107..0d1d4086 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx @@ -73,7 +73,7 @@ EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePart } partBlock->SectorSz = kATASectorSize; - partBlock->SectorStart = kEPMStartPartition + MIB(4); + partBlock->SectorStart = kEPMStartPartition + MIB(16); partBlock->Version = kNewFSVersionInteger; partBlock->Kind = kNewFSPartitionTypeStandard; partBlock->SectorEnd = 0; /// grows on the disk. @@ -97,7 +97,7 @@ EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePart swapBlock->SectorStart = kEPMStartPartition; swapBlock->Version = kNewFSVersionInteger; swapBlock->Kind = kNewFSPartitionTypePage; - swapBlock->SectorEnd = MIB(4); /// 4 MIB swap partition. + swapBlock->SectorEnd = MIB(16); /// 4 MIB swap partition. ataInterface->Write(buf, 1); diff --git a/Private/Source/Framebuffer.cxx b/Private/Source/Framebuffer.cxx index 2682d165..d0be2a13 100644 --- a/Private/Source/Framebuffer.cxx +++ b/Private/Source/Framebuffer.cxx @@ -21,6 +21,14 @@ using namespace NewOS; +namespace NewOS { +const UInt32 kRgbRed = 0x000000FF; +const UInt32 kRgbGreen = 0x0000FF00; +const UInt32 kRgbBlue = 0x00FF0000; +const UInt32 kRgbBlack = 0x00000000; +const UInt32 kRgbWhite = 0xFFFFFFFF; +} // namespace NewOS + /** * @brief Get Pixel at * diff --git a/Public/Developer/System.Core/Headers/Defines.h b/Public/Developer/System.Core/Headers/Defines.h index 36884786..56367cff 100644 --- a/Public/Developer/System.Core/Headers/Defines.h +++ b/Public/Developer/System.Core/Headers/Defines.h @@ -196,9 +196,12 @@ CA_EXTERN_C ObjectRef RtGetAppObject(VoidType); CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType); CA_EXTERN_C CharacterTypeUTF8* RtGetAppArgumentsPtr(VoidType); -CA_INLINE ObjectRef kApplicationObject; +CA_EXTERN_C ObjectRef kApplicationObject; typedef CharacterTypeUTF8 Str255Type[255]; #define True 1 #define False 0 +#define Bool BooleanType + +#define NULL ((PtrVoidType)0) diff --git a/Public/Developer/System.Core/Headers/Window.h b/Public/Developer/System.Core/Headers/Window.h index 714ef7de..846d5cff 100644 --- a/Public/Developer/System.Core/Headers/Window.h +++ b/Public/Developer/System.Core/Headers/Window.h @@ -67,11 +67,11 @@ typedef UInt32Type ColorRef; /// Color utils. /***********************************************************************************/ -const ColorRef kRgbRed = 0x000000FF; -const ColorRef kRgbGreen = 0x0000FF00; -const ColorRef kRgbBlue = 0x00FF0000; -const ColorRef kRgbBlack = 0x00000000; -const ColorRef kRgbWhite = 0xFFFFFFFF; +CA_EXTERN_C const ColorRef kRgbRed; +CA_EXTERN_C const ColorRef kRgbGreen; +CA_EXTERN_C const ColorRef kRgbBlue; +CA_EXTERN_C const ColorRef kRgbBlack; +CA_EXTERN_C const ColorRef kRgbWhite; /***********************************************************************************/ /// Color macro. diff --git a/Public/Developer/System.Core/Makefile b/Public/Developer/System.Core/Makefile index 34851e99..b9a0a663 100644 --- a/Public/Developer/System.Core/Makefile +++ b/Public/Developer/System.Core/Makefile @@ -3,19 +3,21 @@ # This is the SystemLib Makefile. ################################################## -CC=x86_64-w64-mingw32-g++ -CCINC=-I../ -I../../../Private/ -CCFLAGS=-shared -ffreestanding -D__SINGLE_PRECISION__ -nostdlib -fno-rtti -fno-exceptions -std=c++20 -Xlinker --subsystem=17 +CC=x86_64-w64-mingw32-gcc +AR=x86_64-w64-mingw32-ar +ARFLAGS=-rcs +CCINC=-I../ +CCFLAGS=-D__SINGLE_PRECISION__ -nostdlib -std=c17 -ffreestanding -Xlinker --subsystem=17 -shared OUTPUT=SystemLib.lib -.PHONY: build-core-amd64 -build-core-amd64: - $(CC) $(CCINC) $(CCFLAGS) $(wildcard Sources/*.c) $(wildcard Sources/*.cxx) $(wildcard AMD64/*.s) -o $(OUTPUT) - .PHONY: all all: build-core-amd64 @echo "[SystemLib.lib] Build done." +.PHONY: build-core-amd64 +build-core-amd64: + $(CC) $(CCINC) $(CCFLAGS) $(wildcard Sources/*.c) $(wildcard AMD64/*.s) -o $(OUTPUT) + .PHONY: clean clean: - rm -f *.o + rm -f $(wildcard *.o) diff --git a/Public/Developer/System.Core/Sources/New+Delete.cxx b/Public/Developer/System.Core/Sources/New+Delete.cxx deleted file mode 100644 index 0800da22..00000000 --- a/Public/Developer/System.Core/Sources/New+Delete.cxx +++ /dev/null @@ -1,40 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#include - -typedef SizeType size_t; - -void* operator new[](size_t sz) { - if (sz == 0) ++sz; - - return RtAllocateProcessPtr(sz, kStandardAllocation); -} - -void* operator new(size_t sz) { - if (sz == 0) ++sz; - - return RtAllocateProcessPtr(sz, kArrayAllocation); -} - -void operator delete[](void* ptr) { - if (ptr == nullptr) return; - - RtFreeProcessPtr(ptr); -} - -void operator delete(void* ptr) { - if (ptr == nullptr) return; - - RtFreeProcessPtr(ptr); -} - -void operator delete(void* ptr, size_t sz) { - if (ptr == nullptr) return; - CA_UNREFERENCED_PARAMETER(sz); - - RtFreeProcessPtr(ptr); -} diff --git a/Public/Developer/System.Core/Sources/Start.c b/Public/Developer/System.Core/Sources/Start.c index 25a29e18..24d41a1e 100644 --- a/Public/Developer/System.Core/Sources/Start.c +++ b/Public/Developer/System.Core/Sources/Start.c @@ -4,11 +4,12 @@ #include +/// @brief Main Application object, retrieved from __start symbol. +CA_EXTERN_C ObjectRef kApplicationObject = NULL; + /// @brief Inits the library. /// @return if it was succesful or not. -CA_EXTERN_C DWordType __start(VoidType) { +CA_EXTERN_C VoidType __start(VoidType) { kApplicationObject = RtGetAppObject(); CA_MUST_PASS(kApplicationObject); - - return 0; } diff --git a/Public/Developer/System.Core/Sources/Window.c b/Public/Developer/System.Core/Sources/Window.c index 2b589402..b68c1afb 100644 --- a/Public/Developer/System.Core/Sources/Window.c +++ b/Public/Developer/System.Core/Sources/Window.c @@ -59,4 +59,12 @@ CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* id, WmPoint where) { id->windowMoving = True; return 0; -} \ No newline at end of file +} + +/// Colors! + +CA_EXTERN_C const ColorRef kRgbRed = 0x000000FF; +CA_EXTERN_C const ColorRef kRgbGreen = 0x0000FF00; +CA_EXTERN_C const ColorRef kRgbBlue = 0x00FF0000; +CA_EXTERN_C const ColorRef kRgbBlack = 0x00000000; +CA_EXTERN_C const ColorRef kRgbWhite = 0xFFFFFFFF; diff --git a/Public/Developer/System.Cxx/.gitkeep b/Public/Developer/System.Cxx/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Public/Developer/System.Cxx/Sources/New+Delete.cxx b/Public/Developer/System.Cxx/Sources/New+Delete.cxx new file mode 100644 index 00000000..b54b5ea8 --- /dev/null +++ b/Public/Developer/System.Cxx/Sources/New+Delete.cxx @@ -0,0 +1,27 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include + +typedef SizeType size_t; + +void* operator new[](size_t sz) { + if (sz == 0) ++sz; + + return RtAllocateProcessPtr(sz, kStandardAllocation); +} + +void* operator new(size_t sz) { + if (sz == 0) ++sz; + + return RtAllocateProcessPtr(sz, kArrayAllocation); +} + +void operator delete[](void* ptr) { + if (ptr == nullptr) return; + + RtFreeProcessPtr(ptr); +} \ No newline at end of file -- cgit v1.2.3