NeKernel dev
Loading...
Searching...
No Matches
Processor.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#ifdef __NE_ARM64__
10
12#include <NeKit/Array.h>
13#include <NeKit/Config.h>
14#include <NeKit/Utils.h>
15
16#define kCPUBackendName "aarch64"
17
18namespace Kernel::HAL {
19struct PACKED Register64 final {
20 UShort Limit;
21 UIntPtr Base;
22};
23
25enum {
26 kMMFlagsInvalid = 1 << 0,
27 kMMFlagsPresent = 1 << 1,
28 kMMFlagsWr = 1 << 2,
29 kMMFlagsUser = 1 << 3,
30 kMMFlagsNX = 1 << 4,
31 kMMFlagsCount = 4,
32};
33
39EXTERN_C Int32 mm_map_page(VoidPtr virtual_address, VoidPtr physical_address, UInt32 flags,
40 UInt32 level = 2);
41
43
44typedef UIntPtr Reg;
45typedef Register64 Register;
46
48struct PACKED StackFrame {
49 Reg IP;
50 Reg SP;
51 Reg R8;
52 Reg R9;
53 Reg R10;
54 Reg R11;
55 Reg R12;
56 Reg R13;
57 Reg R14;
58 Reg R15;
59};
60
62
63inline Void rt_halt() {
64 while (Yes) {
65 }
66}
67
68inline Void hal_wfi(Void) {
69 asm volatile("wfi");
70}
71} // namespace Kernel::HAL
72
73inline Kernel::VoidPtr kKernelBitMpStart = nullptr;
74inline Kernel::UIntPtr kKernelBitMpSize = 0UL;
75
76#include <HALKit/ARM64/Paging.h>
77
78#endif // __NE_ARM64__
#define PACKED
#define EXTERN_C
#define Yes
The handover boot protocol.
Hardware Abstraction Layer.
Definition ArchKit.h:62
UIntPtr Reg
Definition Processor.h:18
StackFrame * StackFramePtr
Definition Processor.h:34
Void rt_halt()
Definition HalProcessor.cc:70
EXTERN_C UIntPtr mm_get_page_addr(VoidPtr virt)
Gets a physical address from a virtual address.
Definition HalPagingMgr.cc:60
EXTERN_C Int32 mm_map_page(VoidPtr virtual_address, VoidPtr physical_address, UInt32 flags, UInt32 level)
Maps or allocates a page from virtual_address.
Definition HalPagingMgr.cc:120
void Void
Definition Config.h:87
__UINT32_TYPE__ UInt32
Definition Config.h:44
void * VoidPtr
Definition Config.h:33
__INT32_TYPE__ Int32
Definition Config.h:38
__UINT16_TYPE__ UShort
Definition Config.h:39
__UINTPTR_TYPE__ UIntPtr
Definition Config.h:62
Stack frame (as retrieved from assembly.).
Definition Processor.h:21