summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/KernelKit/ZXD.h
blob: 6385448920f0975ad856b4199130da7f47adf607 (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
// 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

#ifndef KERNELKIT_ZXD_H
#define KERNELKIT_ZXD_H

#include <NeKit/Config.h>

#define kZXDMagicNumber (0x2010AF)
#define kZXDVersion (0x0001)

namespace Kernel {

struct ZxdExec;
struct ZxdStub;

enum struct ZxdFlags : Int32 {
  kZXDFlagsInvalid = 0,
  kZXDFlagsDriver  = 120,
  kZXDFlagsBoot,
  kZXDFlagsKernel,
  kZXDFlagsCount = kZXDFlagsKernel - kZXDFlagsDriver + 1,
};

/// @brief ZXD executable header
/// @details This header is used to identify ZXD executable files.
struct PACKED ZxdExec final {
  UInt32  fMagic;
  UInt32  fVersion;
  UInt32  fFlags;
  UInt32  fHdrSize;
  UInt32  fCRC32;
  UInt32  fAssigneeSignature;
  UInt32  fIssuerSingature;
  UIntPtr fExecOffset;
  SizeT   fExecSize;
  UIntPtr fStubOffset;
  SizeT   fStubSize;
  SizeT   fStubAlign;
  SizeT   fStubCount;
};

/// @brief ZXD stub header
/// @details This header is used to identify ZXD stub files. It contains the size of the stub, the
/// offset of the stub, and the CRC32 checksum of the stub.
struct PACKED ZxdStub final {
  Char   fName[8];
  UInt32 fStubSize;
  UInt32 fStubOffset;
  UInt32 fStubCRC32;
};

inline constexpr auto kDriverName = ".drvr";

/// @note This is ProcessSanitizer specific.
inline constexpr auto kProsanName = ".pros";

/// @brief Exec ptr alias.
using ZxdExecPtr = ZxdExec*;
/// @brief Exec stub alias.
using ZxdStubPtr = ZxdStub*;

}  // namespace Kernel

#endif