From b69c498953dc47900e6ccdd0f501727480836f23 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 18 Apr 2025 18:24:44 +0200 Subject: kernel, IMP: GfxKit: GraphicsKit. kernel, IMP: StorageKit: Remove usage of cleanup method on AHCI, DMA, and PIO. Signed-off-by: Amlal El Mahrouss --- dev/kernel/src/Gfx/FBDeviceInterface.cc | 58 +++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 dev/kernel/src/Gfx/FBDeviceInterface.cc (limited to 'dev/kernel/src/Gfx/FBDeviceInterface.cc') diff --git a/dev/kernel/src/Gfx/FBDeviceInterface.cc b/dev/kernel/src/Gfx/FBDeviceInterface.cc new file mode 100644 index 00000000..a9b2be29 --- /dev/null +++ b/dev/kernel/src/Gfx/FBDeviceInterface.cc @@ -0,0 +1,58 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#include + +using namespace Kernel; + +/// @brief Class constructor +/// @param Out Drive output +/// @param In Drive input +/// @param Cleanup Drive cleanup. +FBDeviceInterface::FBDeviceInterface(void (*out)(IDeviceObject* self, FBDevicePacket* outpacket), + void (*in)(IDeviceObject* self, FBDevicePacket* inpacket)) + : IDeviceObject(out, in) +{ +} + +/// @brief Class desctructor +FBDeviceInterface::~FBDeviceInterface() = default; + +/// @brief Output operator. +/// @param mnt the disk mountpoint. +/// @return the class itself after operation. +FBDeviceInterface& FBDeviceInterface::operator<<(FBDevicePacket* pckt) +{ + if (!pckt) + return *this; + + FBDrawInRegion(pckt->fColor, pckt->fHeight, pckt->fWidth, pckt->fY, pckt->fX); + + return *this; +} + +/// @brief Input operator. +/// @param mnt the disk mountpoint. +/// @return the class itself after operation. +FBDeviceInterface& FBDeviceInterface::operator>>(FBDevicePacket* pckt) +{ + if (!pckt) + return *this; + + pckt->fColor = *(((Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * + pckt->fX + + 4 * pckt->fY))); + + return *this; +} + +/// @brief Returns the name of the device interface. +/// @return it's name as a string. +const Char* FBDeviceInterface::Name() const +{ + return "/dev/fb{}"; +} \ No newline at end of file -- cgit v1.2.3 From 6d99a232379317afed814a023fee464001f796ea Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 18 Apr 2025 18:34:33 +0200 Subject: kernel, GfxKit: FIX: Check boundaries to avoid page fault. Signed-off-by: Amlal El Mahrouss --- dev/kernel/src/Gfx/FBDeviceInterface.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'dev/kernel/src/Gfx/FBDeviceInterface.cc') diff --git a/dev/kernel/src/Gfx/FBDeviceInterface.cc b/dev/kernel/src/Gfx/FBDeviceInterface.cc index a9b2be29..525f32b4 100644 --- a/dev/kernel/src/Gfx/FBDeviceInterface.cc +++ b/dev/kernel/src/Gfx/FBDeviceInterface.cc @@ -29,6 +29,13 @@ FBDeviceInterface& FBDeviceInterface::operator<<(FBDevicePacket* pckt) if (!pckt) return *this; + if (pckt->fHeight == 0 || pckt->fWidth == 0) + return *this; + + if (pckt->fX > kHandoverHeader->f_GOP.f_Width || + pckt->fY > kHandoverHeader->f_GOP.f_Height) + return *this; + FBDrawInRegion(pckt->fColor, pckt->fHeight, pckt->fWidth, pckt->fY, pckt->fX); return *this; @@ -42,6 +49,10 @@ FBDeviceInterface& FBDeviceInterface::operator>>(FBDevicePacket* pckt) if (!pckt) return *this; + if (pckt->fX > kHandoverHeader->f_GOP.f_Width || + pckt->fY > kHandoverHeader->f_GOP.f_Height) + return *this; + pckt->fColor = *(((Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * pckt->fX + -- cgit v1.2.3 From 815a1d6538b6748393f6a631a64a1043e49bf3a1 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 18 Apr 2025 18:35:56 +0200 Subject: GfxKit: Gave the correct name for FB device. Signed-off-by: Amlal El Mahrouss --- dev/kernel/GfxKit/FB.h | 51 +++++++++++++++++++++++++++++++++ dev/kernel/GfxKit/Gfx.h | 51 --------------------------------- dev/kernel/src/Gfx/FBDeviceInterface.cc | 2 +- 3 files changed, 52 insertions(+), 52 deletions(-) create mode 100644 dev/kernel/GfxKit/FB.h delete mode 100644 dev/kernel/GfxKit/Gfx.h (limited to 'dev/kernel/src/Gfx/FBDeviceInterface.cc') diff --git a/dev/kernel/GfxKit/FB.h b/dev/kernel/GfxKit/FB.h new file mode 100644 index 00000000..ce5751dc --- /dev/null +++ b/dev/kernel/GfxKit/FB.h @@ -0,0 +1,51 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include +#include + +namespace Kernel +{ + class FBDeviceInterface; + struct FBDevicePacket; + + /// @brief Framebuffer device interface packet. + /// @details This structure is used to send and receive data from the framebuffer device. + /// @note The structure is packed to ensure that the data is aligned correctly for the device. + struct PACKED FBDevicePacket final + { + UInt32 fX; + UInt32 fY; + UInt32 fWidth; + UInt32 fHeight; + UInt32 fColor; + UInt32 fFlags; + }; + + /// @brief Framebuffer device interface. + /// @details This class is used to send and receive data from the framebuffer device. + /// @note The class is derived from the IDeviceObject class. + class FBDeviceInterface NE_DEVICE + { + public: + explicit FBDeviceInterface(void (*out)(IDeviceObject* self, FBDevicePacket* out), + void (*in)(IDeviceObject* self, FBDevicePacket* in)); + + virtual ~FBDeviceInterface() override; + + public: + FBDeviceInterface& operator=(const FBDeviceInterface&) = default; + FBDeviceInterface(const FBDeviceInterface&) = default; + + const Char* Name() const override; + + public: + FBDeviceInterface& operator<<(FBDevicePacket* Data) override; + FBDeviceInterface& operator>>(FBDevicePacket* Data) override; + }; +} // namespace Kernel diff --git a/dev/kernel/GfxKit/Gfx.h b/dev/kernel/GfxKit/Gfx.h deleted file mode 100644 index ce5751dc..00000000 --- a/dev/kernel/GfxKit/Gfx.h +++ /dev/null @@ -1,51 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#pragma once - -#include -#include - -namespace Kernel -{ - class FBDeviceInterface; - struct FBDevicePacket; - - /// @brief Framebuffer device interface packet. - /// @details This structure is used to send and receive data from the framebuffer device. - /// @note The structure is packed to ensure that the data is aligned correctly for the device. - struct PACKED FBDevicePacket final - { - UInt32 fX; - UInt32 fY; - UInt32 fWidth; - UInt32 fHeight; - UInt32 fColor; - UInt32 fFlags; - }; - - /// @brief Framebuffer device interface. - /// @details This class is used to send and receive data from the framebuffer device. - /// @note The class is derived from the IDeviceObject class. - class FBDeviceInterface NE_DEVICE - { - public: - explicit FBDeviceInterface(void (*out)(IDeviceObject* self, FBDevicePacket* out), - void (*in)(IDeviceObject* self, FBDevicePacket* in)); - - virtual ~FBDeviceInterface() override; - - public: - FBDeviceInterface& operator=(const FBDeviceInterface&) = default; - FBDeviceInterface(const FBDeviceInterface&) = default; - - const Char* Name() const override; - - public: - FBDeviceInterface& operator<<(FBDevicePacket* Data) override; - FBDeviceInterface& operator>>(FBDevicePacket* Data) override; - }; -} // namespace Kernel diff --git a/dev/kernel/src/Gfx/FBDeviceInterface.cc b/dev/kernel/src/Gfx/FBDeviceInterface.cc index 525f32b4..c2eb2ca7 100644 --- a/dev/kernel/src/Gfx/FBDeviceInterface.cc +++ b/dev/kernel/src/Gfx/FBDeviceInterface.cc @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include +#include using namespace Kernel; -- cgit v1.2.3