blob: 903e72c880854a4bcb7b1ed2cf4791fe133fed00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/*
* ========================================================
*
* HCore
* Copyright Mahrouss Logic, all rights reserved.
*
* ========================================================
*/
#pragma once
#include <NewKit/Defines.hpp>
#include <NewKit/Function.hpp>
#include <NewKit/Array.hpp>
#ifdef __x86_64__
# include <HALKit/AMD64/Hypervisor.hpp>
# include <HALKit/AMD64/Processor.hpp>
# include <HALKit/AMD64/HalPageAlloc.hpp>
#elif defined(__powerpc64__)
# include <HALKit/PowerPC/Processor.hpp>
#else
# error Unknown architecture
#endif
namespace HCore
{
class SystemCallDefaultImpl final
{
public:
static Int32 Exec() { return 0; }
};
template <SSizeT ID>
class SystemCall
{
public:
explicit SystemCall()
{
kcout << "SystemCall::SystemCall";
}
virtual ~SystemCall()
{
kcout << "SystemCall::~SystemCall";
}
SystemCall &operator=(const SystemCall &) = default;
SystemCall(const SystemCall &) = default;
// Should not be called alone!
virtual bool Exec() const
{
kcout << "SystemCall->Exec<RET>()";
return false;
}
};
constexpr static inline SSizeT syscall_hash(const char *seed, int mul)
{
SSizeT hash = 0;
for (SSizeT idx = 0; seed[idx] != 0; ++idx)
{
hash += seed[idx];
hash ^= mul;
}
return hash;
}
bool ke_init_hal();
} // namespace HCore
#define kMaxSyscalls 0x100
#define kSyscallGate 0x21
extern HCore::Array<void (*)(HCore::Int32 id, HCore::HAL::StackFrame *), kMaxSyscalls> kSyscalls;
extern "C" void rt_wait_for_io();
extern "C" void rt_syscall_handle(HCore::HAL::StackFrame *stack);
extern "C" HCore::HAL::StackFrame* rt_get_current_context();
extern "C" int rt_do_context_switch(HCore::HAL::StackFrame* stackLeft, HCore::HAL::StackFrame* stackRight);
|