NeKernel dev
Loading...
Searching...
No Matches
Config.h
Go to the documentation of this file.
1/* ========================================
2
3 Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
4
5======================================== */
6
7#pragma once
8
9#include <NeKit/Macros.h>
10
11#define NEKIT_VERSION_STR "0.0.1"
12#define NEKIT_VERSION_BCD 0x0001
13
14#ifndef __cplusplus
15#error !!! Kernel compiles only with a C++ compiler. !!!
16#endif
17
18#if __cplusplus <= 201703L
19#define char8_t char
20#endif
21
22#ifdef __has_feature
23#if !__has_feature(cxx_nullptr)
24#if !__has_nullptr
25#error !!! You must at least have nullptr featured on your C++ compiler. !!!
26#endif
27#endif
28#endif
29
31namespace Kernel {
32using voidPtr = void*;
33using VoidPtr = void*;
34using nullPtr = decltype(nullptr);
35using NullPtr = decltype(nullptr);
36
37using Int = int;
38using Int32 = __INT32_TYPE__;
39using UShort = __UINT16_TYPE__;
40using UInt16 = __UINT16_TYPE__;
41using Short = short;
42using Int16 = __INT16_TYPE__;
43using UInt = __UINT32_TYPE__;
44using UInt32 = __UINT32_TYPE__;
45using Long = __INT64_TYPE__;
46using Int64 = __INT64_TYPE__;
47using ULong = __UINT64_TYPE__;
48using UInt64 = __UINT64_TYPE__;
49using Boolean = bool;
50using Bool = bool;
51using Char = char;
52using Int8 = __INT8_TYPE__;
53using Char8 = char8_t;
54using UChar = __UINT8_TYPE__;
55using UInt8 = __UINT8_TYPE__;
56
57using SSize = long;
58using SSizeT = long;
59using Size = __SIZE_TYPE__;
60using SizeT = __SIZE_TYPE__;
61using IntPtr = __INTPTR_TYPE__;
62using UIntPtr = __UINTPTR_TYPE__;
63using IntFast = __INT_FAST32_TYPE__;
64using IntFast64 = __INT_FAST64_TYPE__;
65using PtrDiff = __PTRDIFF_TYPE__;
66
67using SInt16 = Int16;
68using SInt32 = Int32;
69using SInt64 = Int64;
70
71typedef UIntPtr* Ptr64;
72typedef UInt32* Ptr32;
73typedef UInt8* Ptr8;
74
76using Utf16Char = char16_t;
77using WideChar = wchar_t;
78using Utf32Char = char32_t;
79
80using LongDouble = long double;
81using Double = double;
82using Float = float;
83
86
87using Void = void;
88using Any = void*;
89
90using Lba = UInt64;
91
92using Char16 = char16_t;
93
95
100template <typename Args>
101inline Args&& forward(Args& arg) {
102 return static_cast<Args&&>(arg);
103}
104
109template <typename Args>
110inline Args&& move(Args&& arg) {
111 return static_cast<Args&&>(arg);
112}
113
116class ICodec {
117 public:
118 explicit ICodec() = default;
119 virtual ~ICodec() = default;
120
121 ICodec& operator=(const ICodec&) = default;
122 ICodec(const ICodec&) = default;
123
124 public:
129 template <typename T>
130 const Char* AsBytes(T type) {
131 NE_UNUSED(type);
132 return nullptr;
133 }
134
139 template <typename OutputClass, typename FactoryClass>
140 OutputClass* Construct(Char* type) {
141 FactoryClass class_fac;
142 return class_fac.template From<OutputClass>(type);
143 }
144
151 template <typename T, typename Y>
152 Y As(T type) {
153 if (type.template IsSerializable()) {
154 return type.template Error();
155 }
156
157 return type.template As<Y>();
158 }
159};
160
164 public:
165 explicit ISchedulable() = default;
166 virtual ~ISchedulable() = default;
167
169 ISchedulable(const ISchedulable&) = default;
170
172 virtual Bool IsUser() { return NO; }
173
175 virtual Bool IsKernel() { return NO; }
176
178 virtual Bool HasMP() { return NO; }
179};
180} // namespace Kernel
#define char8_t
#define NE_UNUSED(X)
#define NO
ICodec()=default
ICodec & operator=(const ICodec &)=default
virtual ~ICodec()=default
ICodec(const ICodec &)=default
Y As(T type)
Convert T to a Y type.
Definition Config.h:152
OutputClass * Construct(Char *type)
Construct from type to class.
Definition Config.h:140
const Char * AsBytes(T type)
Convert type to bytes.
Definition Config.h:130
ISchedulable(const ISchedulable &)=default
virtual ~ISchedulable()=default
ISchedulable & operator=(const ISchedulable &)=default
virtual Bool IsKernel()
Is this object only accepting kernel tasks?
Definition Config.h:175
virtual Bool HasMP()
Is this object offloading to another CPU?
Definition Config.h:178
virtual Bool IsUser()
Is this object only accepting user tasks?
Definition Config.h:172
Core Types and Macros.
UPS inline definitions.
Definition Device.h:12
char Char
Definition Config.h:51
void Void
Definition Config.h:87
char32_t Utf32Char
Definition Config.h:78
__INT_FAST32_TYPE__ IntFast
Definition Config.h:63
long SSizeT
Definition Config.h:58
char8_t Char8
Definition Config.h:53
__SIZE_TYPE__ Size
Definition Config.h:59
__UINT8_TYPE__ UChar
Definition Config.h:54
__UINT16_TYPE__ UInt16
Definition Config.h:40
Args && forward(Args &arg)
Forward object.
Definition Config.h:101
float Float
Definition Config.h:82
UInt32 PhysicalAddressKind
Definition Config.h:84
Int16 SInt16
Definition Config.h:67
__INT64_TYPE__ Long
Definition Config.h:45
void * voidPtr
Definition Config.h:32
__INT64_TYPE__ Int64
Definition Config.h:46
UInt64 Lba
Definition Config.h:90
Int32 SInt32
Definition Config.h:68
__SIZE_TYPE__ SizeT
Definition Config.h:60
__PTRDIFF_TYPE__ PtrDiff
Definition Config.h:65
UInt8 * Ptr8
Definition Config.h:73
__INT_FAST64_TYPE__ IntFast64
Definition Config.h:64
Endian
Definition Config.h:94
@ kEndianInvalid
Definition Config.h:94
@ kEndianLittle
Definition Config.h:94
@ kEndianBig
Definition Config.h:94
@ kEndianMixed
Definition Config.h:94
@ kEndianCount
Definition Config.h:94
decltype(nullptr) nullPtr
Definition Config.h:34
short Short
Definition Config.h:41
__UINT64_TYPE__ ULong
Definition Config.h:47
long SSize
Definition Config.h:57
UInt32 * Ptr32
Definition Config.h:72
__INT8_TYPE__ Int8
Definition Config.h:52
decltype(nullptr) NullPtr
Definition Config.h:35
__UINT8_TYPE__ UInt8
Definition Config.h:55
__UINT32_TYPE__ UInt32
Definition Config.h:44
__INTPTR_TYPE__ IntPtr
Definition Config.h:61
void * VoidPtr
Definition Config.h:33
void * Any
Definition Config.h:88
__INT32_TYPE__ Int32
Definition Config.h:38
double Double
Definition Config.h:81
Args && move(Args &&arg)
Move object.
Definition Config.h:110
char16_t Char16
Definition Config.h:92
__UINT16_TYPE__ UShort
Definition Config.h:39
long double LongDouble
Definition Config.h:80
char8_t Utf8Char
Definition Config.h:75
int Int
Definition Config.h:37
__INT16_TYPE__ Int16
Definition Config.h:42
bool Boolean
Definition Config.h:49
__UINT32_TYPE__ UInt
Definition Config.h:43
__UINTPTR_TYPE__ UIntPtr
Definition Config.h:62
UIntPtr VirtualAddressKind
Definition Config.h:85
Int64 SInt64
Definition Config.h:69
char16_t Utf16Char
Definition Config.h:76
UIntPtr * Ptr64
Definition Config.h:71
__UINT64_TYPE__ UInt64
Definition Config.h:48
wchar_t WideChar
Definition Config.h:77
bool Bool
Definition Config.h:50