summaryrefslogtreecommitdiffhomepage
path: root/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
blob: 486c1513ce26dd3e04644b7d7c49000481e3e8ac (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
/*
 *	========================================================
 *
 *	HCore
 * 	Copyright Mahrouss Logic, all rights reserved.
 *
 * 	========================================================
 */

#include <ArchKit/ArchKit.hpp>
#include <KernelKit/ProcessManager.hpp>
#include <NewKit/String.hpp>

EXTERN_C void idt_handle_gpf(HCore::UIntPtr rsp) {
  MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent());

  HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp);

  HCore::kcout
      << "General Protection Fault, caused by "
      << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName();

  HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash();
}

extern "C" void idt_handle_scheduler(HCore::UIntPtr rsp) {
  HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp);

  HCore::kcout
      << "HCoreKrnl: Will be scheduled back later "
      << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName()
      << HCore::end_line();

  /// schedule another process.
  if (!HCore::ProcessHelper::StartScheduling()) {
    HCore::kcout << "HCoreKrnl: Continue schedule this process...\r\n";
  }
}

extern "C" void idt_handle_pf(HCore::UIntPtr rsp) {
  HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp);

  MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent());

  HCore::kcout
      << "Segmentation Fault, caused by "
      << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName();

  HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash();
}

extern "C" void idt_handle_math(HCore::UIntPtr rsp) {
  HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp);

  MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent());

  HCore::kcout
      << "Math error, caused by "
      << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName();

  HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash();
}

extern "C" void idt_handle_generic(HCore::UIntPtr rsp) {
  HCore::kcout << HCore::StringBuilder::FromInt("sp{%}", rsp);

  MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent());

  HCore::kcout
      << "Execution error, caused by "
      << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName();

  HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash();
}