summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/HALKit/POWER/Processor.h
blob: a02b99d104a6b1c0732579f30e0aac20f91b0c8d (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
// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/nekernel-org/nekernel

#ifndef HALKIT_PROCESSOR_H
#define HALKIT_PROCESSOR_H

#include <NeKit/Config.h>
#include <NeKit/Utils.h>

#define rtl_nop_op() asm volatile("mr 0, 0")
#define kHalPPCAlignment __attribute__((aligned(4)))

namespace Kernel::HAL {
typedef UIntPtr Reg;

/// @brief Stack frame (as retrieved from assembly.)
struct PACKED StackFrame final {
  Reg R8{0};
  Reg R9{0};
  Reg R10{0};
  Reg R11{0};
  Reg R12{0};
  Reg R13{0};
  Reg R14{0};
  Reg R15{0};
  Reg SP{0};
  Reg IP{0};
};

typedef StackFrame* StackFramePtr;

inline void rt_halt() {
  while (true) {
    NoOp();  // no oop.
  }
}

inline void rt_cli() {
  NoOp();  // no oop
}
}  // namespace Kernel::HAL

EXTERN_C Kernel::Void int_handle_math(Kernel::UIntPtr sp);
EXTERN_C Kernel::Void int_handle_pf(Kernel::UIntPtr sp);

/// @brief Set TLB.
Kernel::Bool hal_set_tlb(Kernel::UInt8 tlb, Kernel::UInt32 epn, Kernel::UInt64 rpn,
                         Kernel::UInt8 perms, Kernel::UInt8 wimge, Kernel::UInt8 ts,
                         Kernel::UInt8 esel, Kernel::UInt8 tsize, Kernel::UInt8 iprot);

/// @brief Write TLB.
Kernel::Void hal_write_tlb(Kernel::UInt32 mas0, Kernel::UInt32 mas1, Kernel::UInt32 mas2,
                           Kernel::UInt32 mas3, Kernel::UInt32 mas7);

/// @brief Flush TLB.
EXTERN_C Kernel::Void hal_flush_tlb();

#endif