From 8051ad2bd4af1f226a9751288957ee6af7e787d7 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Mon, 17 Jun 2024 18:55:38 +0200 Subject: MHR-31: IMP: Add setter for Name. Signed-off-by: Amlal EL Mahrouss --- Drv/GSMDrv/GSMDrv.c | 6 ++++-- Drv/VideoDrv/VideoDrv.c | 4 ++-- Kernel/NetworkKit/NetworkDevice.hpp | 9 +++++++-- Kernel/Sources/Network/NetworkDevice.cxx | 20 +++++++++++++++++++- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/Drv/GSMDrv/GSMDrv.c b/Drv/GSMDrv/GSMDrv.c index 791c0678..1b7cfed6 100644 --- a/Drv/GSMDrv/GSMDrv.c +++ b/Drv/GSMDrv/GSMDrv.c @@ -7,7 +7,8 @@ #include #include -int __ImageStart(void) +/// @brief GSM entrypoint. +int __at_enter(void) { kernelPrintStr("GSMDrv: Starting up...\r"); @@ -16,7 +17,8 @@ int __ImageStart(void) return 0; } -int __ImageEnd(void) +/// @brief GSM 'atexit' function. +int __at_exit(void) { kernelPrintStr("GSMDrv: Shutting down...\r"); return 0; diff --git a/Drv/VideoDrv/VideoDrv.c b/Drv/VideoDrv/VideoDrv.c index 3ba104d6..fc79d2a0 100644 --- a/Drv/VideoDrv/VideoDrv.c +++ b/Drv/VideoDrv/VideoDrv.c @@ -9,13 +9,13 @@ #include -int __ImageStart(void) +int __at_enter(void) { kernelPrintStr("VideoDrv: Starting up...\r"); return 0; } -int __ImageEnd(void) +int __at_exit(void) { kernelPrintStr("VideoDrv: Shutting down...\r"); return 0; diff --git a/Kernel/NetworkKit/NetworkDevice.hpp b/Kernel/NetworkKit/NetworkDevice.hpp index 20c2a66a..4ea98e4f 100644 --- a/Kernel/NetworkKit/NetworkDevice.hpp +++ b/Kernel/NetworkKit/NetworkDevice.hpp @@ -35,12 +35,17 @@ namespace NewOS public: const char* Name() const override; + Boolean Name(const char* strView); private: - void (*fCleanup)(void); + constexpr auto cNetworkNameLen = 512; + + Void (*fCleanup)(void); + Char fNetworkName[cNetworkNameLen]; + }; - struct PACKED NetworkDeviceCommand final + struct NetworkDeviceCommand final { UInt32 CommandName; UInt32 CommandType; diff --git a/Kernel/Sources/Network/NetworkDevice.cxx b/Kernel/Sources/Network/NetworkDevice.cxx index 511246c7..e1994baa 100644 --- a/Kernel/Sources/Network/NetworkDevice.cxx +++ b/Kernel/Sources/Network/NetworkDevice.cxx @@ -8,8 +8,26 @@ namespace NewOS { + /// \brief Getter for fNetworkName. const char* NetworkDevice::Name() const { - return "NetworkDevice"; + return this->fNetworkName; + } + + /// \brief Setter for fNetworkName. + Boolean NetworkDevice::Name(const char* strView) + { + if (strView == nullptr) + return false; + + if (*strView == 0) + return false; + + if (rt_string_len(strView) > cNetworkNameLen) + return false; + + rt_copy_memory(strView, this->fNetworkName, rt_string_len(strView)); + + return true; } } // namespace NewOS -- cgit v1.2.3