diff options
| author | Amlal <amlal@zka.com> | 2024-07-23 12:02:10 +0200 |
|---|---|---|
| committer | Amlal <amlal@zka.com> | 2024-07-23 12:02:10 +0200 |
| commit | 274cba18b8f1c255ddcff2f5c14aab4d0c846820 (patch) | |
| tree | aa56d2223c79d447b85a2bfefdbaab90b25fc8fe | |
| parent | 8eee31685e4334415870bb00b11b6b0d29821f10 (diff) | |
[IMP] User class and current user global.
[REMOVE] ApplicationInterface struct.
[IMP] DDK_STATUS_STRUCT data structure for driver events.
Signed-off-by: Amlal <amlal@zka.com>
| -rw-r--r-- | DDK/KernelStd.h | 12 | ||||
| -rw-r--r-- | Kernel/KernelKit/PermissionSelector.hxx | 57 | ||||
| -rw-r--r-- | Kernel/KernelKit/ProcessScheduler.hxx | 2 | ||||
| -rw-r--r-- | Kernel/KernelKit/User.hxx | 65 | ||||
| -rw-r--r-- | Kernel/NewKit/ApplicationInterface.hxx | 31 | ||||
| -rw-r--r-- | Kernel/Sources/Main.cxx | 6 | ||||
| -rw-r--r-- | Kernel/Sources/User.cxx (renamed from Kernel/Sources/PermissionSelector.cxx) | 25 | ||||
| -rw-r--r-- | Meta/DDK specs.pdf | bin | 0 -> 23051 bytes | |||
| -rw-r--r-- | newoskrnl.files | 5 |
9 files changed, 101 insertions, 102 deletions
diff --git a/DDK/KernelStd.h b/DDK/KernelStd.h index aef1785f..af7bb306 100644 --- a/DDK/KernelStd.h +++ b/DDK/KernelStd.h @@ -11,14 +11,26 @@ #if defined(__cplusplus) #define DK_EXTERN extern "C" #define nil nullptr +#define DK_FINAL final #else #define DK_EXTERN extern #define nil ((void*)0) +#define DK_FINAL #endif // defined(__cplusplus) #include <stdint.h> #include <stddef.h> +struct DDK_STATUS_STRUCT; + +/// \brief DDK status structure (__at_enable, __at_disable...) +struct DDK_STATUS_STRUCT DK_FINAL +{ + int32_t action_id; + int32_t issuer_id; + int32_t group_id; +}; + /// @brief Call kernel (interrupt 0x33) /// @param kernelRpcName /// @param cnt number of elements in **dat** diff --git a/Kernel/KernelKit/PermissionSelector.hxx b/Kernel/KernelKit/PermissionSelector.hxx deleted file mode 100644 index 309e260a..00000000 --- a/Kernel/KernelKit/PermissionSelector.hxx +++ /dev/null @@ -1,57 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ - -#ifndef _INC_PERMISSION_SEL_HXX_ -#define _INC_PERMISSION_SEL_HXX_ - -#include <CompilerKit/CompilerKit.hxx> -#include <NewKit/Defines.hpp> - -// super admin mode user. -#define kMachineUser "Machine" - -// user mode users. -#define kSuperUser "Admin" -#define kGuestUser "Guest" - -// hash 'user@host:password' -> base64 encoded data -// use this data to then fetch specific data. - -namespace Kernel -{ - enum class RingKind - { - kRingUser = 3, - kRingDriver = 2, - kRingKernel = 0, - kRingUnknown = -1, - kRingCount = 4, - }; - - class PermissionSelector final - { - private: - explicit PermissionSelector(const Int32& sel); - explicit PermissionSelector(const RingKind& kind); - - ~PermissionSelector(); - - public: - NEWOS_COPY_DEFAULT(PermissionSelector) - - public: - bool operator==(const PermissionSelector& lhs); - bool operator!=(const PermissionSelector& lhs); - - public: - const RingKind& Ring() noexcept; - - private: - RingKind fRing; - }; -} // namespace Kernel - -#endif /* ifndef _INC_PERMISSION_SEL_HXX_ */ diff --git a/Kernel/KernelKit/ProcessScheduler.hxx b/Kernel/KernelKit/ProcessScheduler.hxx index e5368201..4f9f99f6 100644 --- a/Kernel/KernelKit/ProcessScheduler.hxx +++ b/Kernel/KernelKit/ProcessScheduler.hxx @@ -9,7 +9,7 @@ #include <ArchKit/ArchKit.hpp> #include <KernelKit/LockDelegate.hpp> -#include <KernelKit/PermissionSelector.hxx> +#include <KernelKit/User.hxx> #include <KernelKit/ProcessHeap.hxx> #include <NewKit/MutableArray.hpp> diff --git a/Kernel/KernelKit/User.hxx b/Kernel/KernelKit/User.hxx new file mode 100644 index 00000000..aa0901ac --- /dev/null +++ b/Kernel/KernelKit/User.hxx @@ -0,0 +1,65 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + +------------------------------------------- */ + +#ifndef _INC_PERMISSION_SEL_HXX_ +#define _INC_PERMISSION_SEL_HXX_ + +#include <CompilerKit/CompilerKit.hxx> +#include <NewKit/String.hpp> +#include <NewKit/Defines.hpp> + +// user mode users. +#define kSuperUser "Admin" +#define kGuestUser "Guest" + +#define kUsersDir "\\Users\\Store\\" + +#define kMaxUserNameLen (255) + +// hash 'password' -> base64+md5 encoded data +// use this data to then fetch specific data of the user.. + +namespace Kernel +{ + enum class RingKind + { + kRingStdUser = 1, + kRingSuperUser = 2, + kRingGuestUser = 5, + kRingCount = 5, + }; + + class User final + { + public: + explicit User() = default; + + User(const Int32& sel, const Char* userName); + User(const RingKind& kind, const Char* userName); + + ~User(); + + public: + NEWOS_COPY_DEFAULT(User) + + public: + bool operator==(const User& lhs); + bool operator!=(const User& lhs); + + public: + const RingKind& Ring() noexcept; + const StringView Name() noexcept; + + private: + RingKind fRing{RingKind::kRingStdUser}; + StringView fUserName{kMaxUserNameLen}; + + }; + + inline User* cRootUser = nullptr; +} // namespace Kernel + +#endif /* ifndef _INC_PERMISSION_SEL_HXX_ */ diff --git a/Kernel/NewKit/ApplicationInterface.hxx b/Kernel/NewKit/ApplicationInterface.hxx deleted file mode 100644 index 31da9aa3..00000000 --- a/Kernel/NewKit/ApplicationInterface.hxx +++ /dev/null @@ -1,31 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ - -#pragma once - -/// -/// @brief Application object, given by the OS to the process. interact with the OS. -/// @file ApplicationInterface.hxx -/// @author Amlal EL Mahrouss -/// - -#include <NewKit/Defines.hpp> -#include <CFKit/GUIDWrapper.hpp> - -/// \brief Application Interface. -/// \author Amlal El Mahrouss -typedef struct _ApplicationInterface final -{ - /// @brief Releases the object exit the process on main object. - Kernel::Void (*Release)(struct _Application* Self, Kernel::Int32 ExitCode); - /// @brief Invoke a function from the application object. - Kernel::IntPtr (*Invoke)(struct _Application* Self, Kernel::Int32 Sel, ...); - /// @brief Query a new application object from a GUID. - /// @note this doesn't query a process, it query a registered object withtin that app. - Kernel::Void (*Query)(struct _Application* Self, Kernel::VoidPtr* Dst, Kernel::SizeT SzDst, Kernel::XRN::GUIDSequence GuidOf); -} ApplicationInterface, *ApplicationInterfaceRef; - -#define app_cast reinterpret_cast<ApplicationInterfaceRef> diff --git a/Kernel/Sources/Main.cxx b/Kernel/Sources/Main.cxx index 92dac251..b0083730 100644 --- a/Kernel/Sources/Main.cxx +++ b/Kernel/Sources/Main.cxx @@ -63,7 +63,7 @@ namespace Kernel::Detail const auto cDirCount = 9; const char* cDirStr[cDirCount] = { "\\Boot\\", "\\System\\", "\\Support\\", "\\Applications\\", - "\\Users\\", "\\Library\\", "\\Mounted\\", "\\DCIM\\", "\\Applications\\Storage\\"}; + "\\Users\\", "\\Library\\", "\\Mounted\\", "\\DCIM\\", "\\Applications\\Store\\"}; for (Kernel::SizeT dirIndx = 0UL; dirIndx < cDirCount; ++dirIndx) { @@ -188,6 +188,10 @@ namespace Kernel::Detail /// @return void no return value. STATIC Kernel::Void ke_user_switch(Kernel::Void) { + + Kernel::cRootUser = new User(RingKind::kRingSuperUser, kSuperUser); + Kernel::kcout << "newoskrnl: logged in as: " << Kernel::cRootUser->Name().CData() << Kernel::endl; + Kernel::kcout << "newoskrnl: " << cKernelVersion.GetKey().CData() << ": " << Kernel::number(cKernelVersion.GetValue()) << Kernel::endl; } } // namespace Kernel::Detail diff --git a/Kernel/Sources/PermissionSelector.cxx b/Kernel/Sources/User.cxx index 726f34e1..1deac5be 100644 --- a/Kernel/Sources/PermissionSelector.cxx +++ b/Kernel/Sources/User.cxx @@ -4,43 +4,50 @@ * Kernel * Copyright ZKA Technologies, all rights reserved. * - * File: PermissionSelector.cpp + * File: User.cpp * Purpose: Permission selectors. * * ======================================================== */ -#include <KernelKit/PermissionSelector.hxx> +#include <KernelKit/User.hxx> #include <NewKit/KernelCheck.hpp> /// bugs 0 namespace Kernel { - PermissionSelector::PermissionSelector(const Int32& sel) + User::User(const Int32& sel, const Char* userName) : fRing((RingKind)sel) { - MUST_PASS(sel > 0); + MUST_PASS(sel >= 0); + this->fUserName += userName; } - PermissionSelector::PermissionSelector(const RingKind& ringKind) + User::User(const RingKind& ringKind, const Char* userName) : fRing(ringKind) { + this->fUserName += userName; } - PermissionSelector::~PermissionSelector() = default; + User::~User() = default; - bool PermissionSelector::operator==(const PermissionSelector& lhs) + bool User::operator==(const User& lhs) { return lhs.fRing == this->fRing; } - bool PermissionSelector::operator!=(const PermissionSelector& lhs) + bool User::operator!=(const User& lhs) { return lhs.fRing != this->fRing; } - const RingKind& PermissionSelector::Ring() noexcept + const StringView User::Name() noexcept + { + return this->fUserName; + } + + const RingKind& User::Ring() noexcept { return this->fRing; } diff --git a/Meta/DDK specs.pdf b/Meta/DDK specs.pdf Binary files differnew file mode 100644 index 00000000..c3af60cf --- /dev/null +++ b/Meta/DDK specs.pdf diff --git a/newoskrnl.files b/newoskrnl.files index d8988b7b..c626b783 100644 --- a/newoskrnl.files +++ b/newoskrnl.files @@ -176,7 +176,7 @@ Kernel/KernelKit/PECodeManager.hxx Kernel/KernelKit/PEF.hxx
Kernel/KernelKit/PEFCodeManager.hxx
Kernel/KernelKit/PEFSharedObject.hxx
-Kernel/KernelKit/PermissionSelector.hxx
+Kernel/KernelKit/User.hxx
Kernel/KernelKit/ProcessScheduler.hxx
Kernel/KernelKit/SMPManager.hpp
Kernel/KernelKit/Semaphore.hpp
@@ -216,7 +216,6 @@ Kernel/NetworkKit/LTE.hxx Kernel/NetworkKit/MAC.hxx
Kernel/NetworkKit/NetworkDevice.hpp
Kernel/NetworkKit/compile_flags.txt
-Kernel/NewKit/ApplicationInterface.hxx
Kernel/NewKit/Array.hpp
Kernel/NewKit/ArrayList.hpp
Kernel/NewKit/Atom.hpp
@@ -279,7 +278,7 @@ Kernel/Sources/PEFSharedObject.cxx Kernel/Sources/PRDT.cxx
Kernel/Sources/PageAllocator.cxx
Kernel/Sources/PageManager.cxx
-Kernel/Sources/PermissionSelector.cxx
+Kernel/Sources/User.cxx
Kernel/Sources/Pmm.cxx
Kernel/Sources/ProcessScheduler.cxx
Kernel/Sources/ProcessTeam.cxx
|
