NeKernel dev
Loading...
Searching...
No Matches
ArchKit.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/Array.h>
10#include <NeKit/Config.h>
11#include <NeKit/Function.h>
12
14
15#ifdef __NE_AMD64__
17#include <HALKit/AMD64/Paging.h>
19#elif defined(__NE_POWER64__)
21#elif defined(__NE_ARM64__)
23#elif defined(__NE_SDK__)
25#else
26#error !!! unknown architecture !!!
27#endif
28
29#define kMaxDispatchCallCount (512U)
30
31namespace Kernel {
32inline SizeT rt_hash_seed(const Char* seed, UInt32 mul) {
33 SizeT hash = 0;
34
35 for (SSizeT idx = 0; seed[idx] != 0; ++idx) {
36 hash += seed[idx];
37 hash ^= mul;
38 }
39
40 return hash;
41}
42
47template <typename DataKind>
48inline Void ke_dma_write(UIntPtr base, DataKind reg, DataKind value) {
49 *(volatile DataKind*) (base + reg) = value;
50}
51
56template <typename DataKind>
57inline UInt32 ke_dma_read(UIntPtr base, DataKind reg) {
58 return *(volatile DataKind*) (base + reg);
59}
60
62namespace HAL {
67} // namespace HAL
68} // namespace Kernel
69
71
73struct HAL_DISPATCH_ENTRY final {
77
78 BOOL IsKernCall() { return NO; }
79 BOOL IsSysCall() { return YES; }
80
81 operator bool() { return fHooked; }
82};
83
85
91
92 BOOL IsKernCall() { return YES; }
93 BOOL IsSysCall() { return NO; }
94
95 operator bool() { return fHooked; }
96};
97
99
101
102#ifdef __NE_VIRTUAL_MEMORY_SUPPORT__
103
104inline Kernel::VoidPtr kKernelVM = nullptr;
105
106#endif // __NE_VIRTUAL_MEMORY_SUPPORT__
107
Kernel::Array< HAL_DISPATCH_ENTRY, kMaxDispatchCallCount > kSysCalls
Definition ArchKit.h:98
Kernel::Void(* rt_kerncall_proc)(Kernel::SizeT, Kernel::VoidPtr, Kernel::SizeT)
Definition ArchKit.h:84
Kernel::SizeT kBitMapCursor
Definition ArchKit.h:108
Kernel::Void(* rt_syscall_proc)(Kernel::VoidPtr)
Definition ArchKit.h:70
Kernel::Array< HAL_KERNEL_DISPATCH_ENTRY, kMaxDispatchCallCount > kKernCalls
Definition ArchKit.h:100
#define YES
#define NO
#define BOOL
The handover boot protocol.
Definition Array.h:15
Hardware Abstraction Layer.
Definition ArchKit.h:62
auto mm_is_bitmap(VoidPtr ptr) -> Bool
Check whether this pointer is a bitmap object.
UPS inline definitions.
Definition Device.h:12
char Char
Definition Config.h:51
void Void
Definition Config.h:87
long SSizeT
Definition Config.h:58
SizeT rt_hash_seed(const Char *seed, UInt32 mul)
Definition ArchKit.h:32
__SIZE_TYPE__ SizeT
Definition Config.h:60
__UINT32_TYPE__ UInt32
Definition Config.h:44
void * VoidPtr
Definition Config.h:33
Void ke_dma_write(UIntPtr base, DataKind reg, DataKind value)
write to mapped memory register
Definition ArchKit.h:48
UInt32 ke_dma_read(UIntPtr base, DataKind reg)
read from mapped memory register.
Definition ArchKit.h:57
__UINTPTR_TYPE__ UIntPtr
Definition Config.h:62
__UINT64_TYPE__ UInt64
Definition Config.h:48
bool Bool
Definition Config.h:50
System Call Dispatch.
Definition ArchKit.h:73
BOOL IsSysCall()
Definition ArchKit.h:79
Kernel::Bool fHooked
Definition ArchKit.h:75
Kernel::UInt64 fHash
Definition ArchKit.h:74
BOOL IsKernCall()
Definition ArchKit.h:78
rt_syscall_proc fProc
Definition ArchKit.h:76
Kernel Call Dispatch.
Definition ArchKit.h:87
rt_kerncall_proc fProc
Definition ArchKit.h:90
BOOL IsSysCall()
Definition ArchKit.h:93
Kernel::UInt64 fHash
Definition ArchKit.h:88
BOOL IsKernCall()
Definition ArchKit.h:92
Kernel::Bool fHooked
Definition ArchKit.h:89