summaryrefslogtreecommitdiffhomepage
path: root/src/boot/modules/MemoryTest/MemoryTest.cpp
blob: 49f28dcb2e2acff44295e3699b16bd8abb769236 (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
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/ne-foss-org/nekernel

#include <BootKit/BootKit.h>
#include <BootKit/BootThread.h>
#include <FirmwareKit/EFI/API.h>

EXTERN_C Int32 MemoryTestModuleMain(Kernel::HEL::BootInfoHeader* handover) {
  fw_init_efi((EfiSystemTable*) handover->f_FirmwareCustomTables[Kernel::HEL::kHandoverTableST]);

  Boot::BootTextWriter writer;
  writer.Write("MemoryTest: Testing Memory...\r");

  constexpr auto kTestValue = 0x20000000L;

  Int32* mem = (Int32*) kTestValue;
  if (!mem) return kEfiFail;

  auto prev = *mem;
  *mem      = 42;
  if (*mem != 42) {
    return kEfiFail;
  }

  *mem = prev;

  return kEfiOk;
}