diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-25 20:17:53 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-25 20:17:53 +0100 |
| commit | 3b3b36dcc6542e203475fe1d50ed89799e3f3fc6 (patch) | |
| tree | 3d1e4cfba79343e2b5ef8db58c58271009a44937 /Private | |
| parent | d968190d1ba48638c1481be0d367ee3cea82ae55 (diff) | |
Kernel: implement some tickets, improved stuff.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Private')
| -rw-r--r-- | Private/KernelKit/Framebuffer.hpp | 22 | ||||
| -rw-r--r-- | Private/ObjectKit/ObjectKit.hxx | 3 | ||||
| -rw-r--r-- | Private/Source/Framebuffer.cxx | 32 | ||||
| -rw-r--r-- | Private/Source/KernelHeap.cxx | 10 |
4 files changed, 54 insertions, 13 deletions
diff --git a/Private/KernelKit/Framebuffer.hpp b/Private/KernelKit/Framebuffer.hpp index daf95ed0..0dfeacef 100644 --- a/Private/KernelKit/Framebuffer.hpp +++ b/Private/KernelKit/Framebuffer.hpp @@ -28,7 +28,8 @@ class FramebufferContext final { class Framebuffer final { public: - explicit Framebuffer(Ref<FramebufferContext *> &addr) : m_FrameBufferAddr(addr) {} + explicit Framebuffer(Ref<FramebufferContext *> &addr) + : m_FrameBufferAddr(addr) {} ~Framebuffer() {} Framebuffer &operator=(const Framebuffer &) = delete; @@ -37,12 +38,29 @@ class Framebuffer final { volatile UIntPtr *operator[](const UIntPtr &pos); operator bool(); - + const FramebufferColorKind &Color( const FramebufferColorKind &colour = FramebufferColorKind::INVALID); Ref<FramebufferContext *> &Leak(); + /// @brief Draws a rectangle inside the fb. + /// @param width + /// @param height + /// @param x + /// @param y + /// @param color + /// @return + Framebuffer &DrawRect(SizeT width, SizeT height, SizeT x, SizeT y, + UInt32 color); + + /// @brief Puts a pixel on the screen. + /// @param x where in X + /// @param y where in Y + /// @param color the color of it. + /// @return + Framebuffer &PutPixel(SizeT x, SizeT y, UInt32 color); + private: Ref<FramebufferContext *> m_FrameBufferAddr; FramebufferColorKind m_Colour; diff --git a/Private/ObjectKit/ObjectKit.hxx b/Private/ObjectKit/ObjectKit.hxx index 904e23cb..744f8a61 100644 --- a/Private/ObjectKit/ObjectKit.hxx +++ b/Private/ObjectKit/ObjectKit.hxx @@ -9,8 +9,7 @@ #include <NewKit/Defines.hpp> #include <CFKit/GUIDWrapper.hpp> -#define kObjectGlobalNamespaceSystem "HCORE_ROOT\\" -#define kObjectGlobalNamespaceUser "HCORE_USER_ROOT\\" +#define kObjectGlobalNamespace ":\\" enum { kObjectTypeProcess, diff --git a/Private/Source/Framebuffer.cxx b/Private/Source/Framebuffer.cxx index 6ea2fa5b..9c964a3c 100644 --- a/Private/Source/Framebuffer.cxx +++ b/Private/Source/Framebuffer.cxx @@ -33,13 +33,14 @@ volatile UIntPtr *Framebuffer::operator[](const UIntPtr &pos) { /// @brief Boolean operator. Framebuffer::operator bool() { - return m_FrameBufferAddr.Leak()->m_Base != 0 && m_Colour != FramebufferColorKind::INVALID && - m_FrameBufferAddr.Leak()->m_Base != kBadPtr; + return m_FrameBufferAddr.Leak()->m_Base != 0 && + m_Colour != FramebufferColorKind::INVALID && + m_FrameBufferAddr.Leak()->m_Base != kBadPtr; } /// @brief Set color kind of framebuffer. -/// @param colour -/// @return +/// @param colour +/// @return const FramebufferColorKind &Framebuffer::Color( const FramebufferColorKind &colour) { if (m_Colour != FramebufferColorKind::INVALID && @@ -50,8 +51,29 @@ const FramebufferColorKind &Framebuffer::Color( return m_Colour; } -/// @brief Leak fraembuffer context. +/// @brief Leak framebuffer context. /// @return The reference of the framebuffer context. Ref<FramebufferContext *> &Framebuffer::Leak() { return this->m_FrameBufferAddr; } + +Framebuffer &Framebuffer::DrawRect(SizeT width, SizeT height, SizeT x, SizeT y, + UInt32 color) { + for (HCore::SizeT i = x; i < width + x; ++i) { + for (HCore::SizeT u = y; u < height + y; ++u) { + *(((volatile HCore::UInt32 *)(m_FrameBufferAddr.Leak()->m_Base + + 4 * m_FrameBufferAddr.Leak()->m_Bpp * i + + 4 * u))) = color; + } + } + + return *this; +} + +Framebuffer &Framebuffer::PutPixel(SizeT x, SizeT y, UInt32 color) { + *(((volatile HCore::UInt32 *)(m_FrameBufferAddr.Leak()->m_Base + + 4 * m_FrameBufferAddr.Leak()->m_Bpp * x + + 4 * y))) = color; + + return *this; +}
\ No newline at end of file diff --git a/Private/Source/KernelHeap.cxx b/Private/Source/KernelHeap.cxx index a38156f4..39648102 100644 --- a/Private/Source/KernelHeap.cxx +++ b/Private/Source/KernelHeap.cxx @@ -75,8 +75,9 @@ Int32 ke_delete_ke_heap(VoidPtr heapPtr) { if (virtualAddress->hCRC32 != 0) { if (virtualAddress->hCRC32 != ke_calculate_crc32((Char *)virtualAddress->hAddress, - virtualAddress->hSizeAddress)) + virtualAddress->hSizeAddress)) { ke_stop(RUNTIME_CHECK_POINTER); + } } virtualAddress->hSizeAddress = 0UL; @@ -112,8 +113,8 @@ Boolean ke_is_valid_heap(VoidPtr heapPtr) { } /// @brief Protect the heap pointer with a CRC32. -/// @param heapPtr -/// @return +/// @param heapPtr +/// @return Boolean ke_protect_ke_heap(VoidPtr heapPtr) { if (heapPtr) { Detail::HeapInformationBlockPtr virtualAddress = @@ -121,7 +122,8 @@ Boolean ke_protect_ke_heap(VoidPtr heapPtr) { (UIntPtr)heapPtr - sizeof(Detail::HeapInformationBlock)); if (virtualAddress->hPresent && virtualAddress->hMagic == kHeapMagic) { - virtualAddress->hCRC32 = ke_calculate_crc32((Char*)heapPtr, virtualAddress->hSizeAddress); + virtualAddress->hCRC32 = + ke_calculate_crc32((Char *)heapPtr, virtualAddress->hSizeAddress); return true; } } |
