summaryrefslogtreecommitdiffhomepage
path: root/src/boot/modules/SysChk/SysChk.cpp
blob: e8c5af06dfbeff9d249b09f2a9b41a72ef7ddd6a (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
// 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/ne-foss-org/nekernel

#include <BootKit/BootKit.h>
#include <BootKit/BootThread.h>
#include <BootKit/HW/SATA.h>
#include <FirmwareKit/EFI.h>
#include <FirmwareKit/EFI/API.h>
#include <FirmwareKit/Handover.h>
#include <KernelKit/MSDOS.h>
#include <KernelKit/PE.h>
#include <KernelKit/PEF.h>
#include <NeKit/Macros.h>
#include <NeKit/Ref.h>
#include <modules/CoreGfx/CoreGfx.h>
#include <modules/CoreGfx/TextGfx.h>

// Makes the compiler shut up.
#ifndef kMachineModel
#define kMachineModel "OS"
#endif  // !kMachineModel

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

#if defined(__ATA_PIO__)
  Boot::BDiskFormatFactory<Boot::BootDeviceATA> partition_factory;
#elif defined(__AHCI__)
  Boot::BDiskFormatFactory<Boot::BootDeviceSATA> partition_factory;
#endif

  if (partition_factory.IsPartitionValid()) return kEfiOk;

  return partition_factory.Format(kMachineModel);
}