summaryrefslogtreecommitdiffhomepage
path: root/dev/boot/modules/SysChk/SysChk.cc
blob: dec4e11a21a42e2aba4be379b074fd9b94bcddb9 (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
/*
 *	========================================================
 *
 *	SysChk
 * 	Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
 *
 * 	========================================================
 */

#include <BootKit/BootKit.h>
#include <modules/CoreGfx/CoreGfx.h>
#include <modules/CoreGfx/TextGfx.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 <NewKit/Macros.h>
#include <NewKit/Ref.h>
#include <BootKit/BootThread.h>
#include <modules/CoreGfx/CoreGfx.h>

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

EXTERN_C Int32 SysChkModuleMain(Kernel::HEL::BootInfoHeader* handover)
{
	NE_UNUSED(handover);

#ifdef __ATA_PIO__
	Boot::BDiskFormatFactory<BootDeviceATA> partition_factory;

	if (partition_factory.IsPartitionValid())
		return kEfiOk;

	Boot::BDiskFormatFactory<BootDeviceATA>::BFileDescriptor desc{};

	desc.fFileName[0] = '/';
	desc.fFileName[1] = 0;
	desc.fKind		  = kNeFSCatalogKindDir;

	partition_factory.Format(kMachineModel, &desc, 1);

	if (partition_factory.IsPartitionValid())
		return kEfiOk;

	return kEfiFail;
#else
	return kEfiOk;
#endif
}